Write EXIF into JPG with PHP

Go To StackoverFlow.com

4

For a couple of days I'm trying to write (or update) EXIF information (geotag, latitude and longitude) in a JPG image using PHP. After consulting many sites without success I think the best option is to use Imagick but although it seems I can set the latitude and longitude with setImageProperty(), but when I write the picture the EXIF is not saved.

Here I give a code fragment:

//Loading existing image
$edited = new Imagick(dirname(__FILE__)."/mini.jpg");
//Stripping the curren EXIF info. I think is not mandatory and I try to comment but nothing...
$edited->stripImage();
//Setting the new properties
$edited->setImageProperty('exif:GPSLatitude', '30/1, 46/1, 58605/1000');
$edited->setImageProperty('exif:GPSLongitude', '63/1, 57/1, 35550/1000');
$propiedades = $edited->getImageProperties();
var_dump($propiedades);
var_dump($edited->writeImage('mini_edited.jpg'));


//reading the new image EXIF Info
$readedited = new Imagick(dirname(__FILE__)."/mini_edited.jpg");
$propiedades_edited = $readedited->getImageProperties();

The image is saved successfully but no the exif information updates.

Anyone have an idea how I can solve this problem with this or any other tool? The only requirement is to use PHP

Thank you very much in advance!

2012-04-03 20:37
by CesarTrigo
possible duplicate of How do I add exif data to an image?Brad 2012-04-03 21:21
@Brad thanks for the link - CesarTrigo 2014-11-15 16:47


5

The only way I've found is to install PEL - the PHP Exif Library

2012-04-04 12:01
by Terence Eden
Terecen Eden, I've been testing PEL appears to work well. Thank you - CesarTrigo 2012-04-04 15:27
broken link, current link https://github.com/pel/pe - ZJR 2019-01-25 10:46


-2

The gd or ImageMagick libraries will help you do this sort of thing. If you are using shared hosting one (or both of them) may have been installed for you.

2012-04-04 12:37
by Annabel
Thanks but seems gb ad ImageMagick cant write EXIF tag - CesarTrigo 2012-04-04 15:25