使用 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屋!