Write EXIF into JPG with PHP

放肆的年华 提交于 2019-12-30 07:01:14

问题


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!


回答1:


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




回答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.



来源:https://stackoverflow.com/questions/10001012/write-exif-into-jpg-with-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!