【问题标题】:How to Remove EXIF (image file) data in PHP?如何在 PHP 中删除 EXIF(图像文件)数据?
【发布时间】:2018-06-28 11:29:59
【问题描述】:

我已经安装了 imagick 库并使用以下命令进行了检查: php -m | grep imagick。这是工作。 但是当我提到相同的参考时,它给了我空白数组。

这是我的代码:

    error_reporting(E_ALL);
    $incoming_file = '/var/www/html/demos/exif/tim.jpg';
    $img = new Imagick(realpath($incoming_file));
    $profiles = $img->getImageProfiles("icc", true);
    echo '<pre>';
    print_r($profiles); 

当我尝试打印 $profiles 时,没有返回任何内容。它给了我一个空数组。

Reference Link for exif data in php

【问题讨论】:

  • 所有图像都没有嵌入 icc 配置文件。如果您得到一个空响应,请跳过该步骤。
  • 然而我没有工作

标签: php exif


【解决方案1】:

这将在 PHP 中显示来自 JPEG 文件的 EXIF 信息。尝试使用相对路径并检查脚本是否可以从此目录读取(权限)。

$uploadfile = "uploaded/pic.jpg";
$exif = exif_read_data($uploadfile, 0, true);
echo "<b>Your file</b><br />\n";
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        echo "$key.$name: $val<br />\n";
    }
}

并且这段代码应该删除所有的EXIF信息

$img = new Imagick($uploadfile);
$img->stripImage();
$img->writeImage($uploadfile);

你可以在这里试试: https://iconnaut.com/exif.php

【讨论】:

    猜你喜欢
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    • 2015-02-22
    相关资源
    最近更新 更多