使用PHP将EXIF写入JPG

5

最近几天,我一直在尝试使用PHP编写(或更新)JPG图像中的EXIF信息(地理标记、纬度和经度)。在查阅了许多网站后仍然没有成功,我认为最好的选择是使用Imagick。虽然似乎可以使用setImageProperty()设置纬度和经度,但当我写入图片时,EXIF并未保存。

以下是代码片段:

//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();

图片已成功保存,但是exif信息未更新。有没有什么方法可以解决这个问题,使用PHP实现即可。谢谢!

可能是重复的问题:如何向图像添加exif数据? - Brad
@Brad,感谢你提供的链接! - CesarTrigo
2个回答

6

Terecen Eden,我一直在测试PEL,看起来它运行良好。 谢谢! - CesarTrigo

-3

gdImageMagick库可以帮助您完成此类操作。如果您正在使用共享主机,则可能已为您安装其中一个(或两个)。


2
谢谢,但似乎GB和ImageMagick都无法写入EXIF标签。 - CesarTrigo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接