I having some problems with an image that has EXIF/IPTC data stored in it.
When I use imageCreateFromJpeg
(to rotate/crop or etc) the newly stored file doesn't preserve the EXIF/IPTC data.
My current code looks like this:
<?php
// Before executing - EXIF/IPTC data is there (checked)
$image = "/path/to/my/image.jpg";
$source = imagecreatefromjpeg($image);
$rotate = imagerotate($source,90,0);
imageJPEG($rotate,$image);
// After executing - EXIF/IPTC data doesn't exist anymore.
?>
Am I doing something wrong?
You aren't doing anything wrong, but GD doesn't deal with Exif of IPTC data at all as its beyond the scope of what GD does.
You will have to use a 3rd party library or other PHP extension to read the data from the source image and re-insert it to the output image created by imagejpeg
.
Here are some libraries of interest: pel (php exif library), an example on php.net showing how to use pel to do what you want, php metadata toolkit, iptcembed() function.