Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick Preserve Exif Data

I have a resizing function that does it's primary job right, but doesn't save the exif data that comes with the original image file. Everything seems to be correct until I call ->writeImage(); function, which seems to strip the exif data of the image.

$resizeimage= new Imagick($image);

$exifDataArray = $resizeimage->getImageProperties("exif:*");

$resizeimage->thumbnailImage($width,$height);

$resizeimage->setImageCompression(imagick::COMPRESSION_JPEG); 
$resizeimage->setImageCompressionQuality(90); 

echo $resizeimage->setImageProperty('Exif:Make', 'BLABLABLA');

$resizeimage->writeImage();


$updated= new Imagick($image);
echo $updated->getImageProperty('Exif:Make');

Note that If I print_r($exifDataArray); it shows the exif data To make a change I put 'Exif:Make', 'BLABLABLA' and see if the new exif data is written on the image, and it is written correctly

but after I resizeimage->writeImage(); No more exif data is present on the image file.

Can anybody help? Is there any way to keep the exif data on the image?

like image 461
inrob Avatar asked Dec 26 '22 11:12

inrob


1 Answers

It seems the error isn't there for the first time.

A workaround I use at the moment:

exiftool -overwrite_original_in_place -tagsFromFile $source_file $converted_file
like image 87
nadar Avatar answered Dec 28 '22 10:12

nadar