使用PHP从JPG中删除EXIF数据 [英] Remove EXIF data from JPG using PHP
问题描述
有没有办法使用PHP从JPG中删除EXIF数据?我听说过PEL,但我希望有一种更简单的方法。我正在上传将在线显示的图片,并希望删除EXIF数据。
Is there any way to remove the EXIF data from a JPG using PHP? I have heard of PEL, but I'm hoping there's a simpler way. I am uploading images that will be displayed online and would like the EXIF data removed.
谢谢!
编辑:我没有/无法安装ImageMagick。
I don't/can't install ImageMagick.
推荐答案
使用 gd
以新的方式重新创建图像的图形部分,将 保存为其他名称 。
Use gd
to recreate the graphical part of the image in a new one, that you save with another name.
请参阅 PHP gd
编辑2017
使用新的Imagick功能。
Use the new Imagick feature.
打开图片:
<?php
$incoming_file = '/Users/John/Desktop/file_loco.jpg';
$img = new Imagick(realpath($incoming_file));
请务必在图片中保留任何ICC个人资料
Be sure to keep any ICC profile in the image
$profiles = $img->getImageProfiles("icc", true);
然后剥离图像,如果有任何
then strip image, and put the profile back if any
$img->stripImage();
if(!empty($profiles)) {
$img->profileImage("icc", $profiles['icc']);
}
来自这个PHP页面,请参阅Max Eremin的评论。
Comes from this PHP page, see comment from Max Eremin down the page.
这篇关于使用PHP从JPG中删除EXIF数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!