用PHP将EXIF写入JPG [英] Write EXIF into JPG with PHP
问题描述
几天以来,我一直在尝试使用PHP在JPG图像中写入(或更新)EXIF信息(地理标记,纬度和经度). 在咨询了很多网站之后,我认为最好的选择是使用Imagick,但是尽管我可以使用setImageProperty()设置纬度和经度,但是当我写图片时,EXIF并没有保存.
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();
图像已成功保存,但没有exif信息更新.
The image is saved successfully but no the exif information updates.
任何人都知道如何使用此工具或任何其他工具解决此问题? 唯一的要求是使用PHP
Anyone have an idea how I can solve this problem with this or any other tool? The only requirement is to use PHP
非常感谢您!
推荐答案
我发现的唯一方法是安装 PEL-PHP Exif库
The only way I've found is to install PEL - the PHP Exif Library
这篇关于用PHP将EXIF写入JPG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!