Which image formats contain meta data, and how can I clear it in PHP?

南楼画角 提交于 2019-12-05 07:08:08

The easiest way is to copy them to a new image with GD - you keep all the image info, but get rid of the metadata.

You may try http://www.php.net/manual/en/imagick.stripimage.php

$f = '16262403.jpg';
$i = new Imagick($f);
$p = $i->getImageProperties();
var_dump($p);
array(5) {
  ["comment"]=>
  string(20) "(C) Drom.ru #4495317"
  ["date:create"]=>
  string(25) "2012-05-29T17:15:32+03:00"
  ["date:modify"]=>
  string(25) "2012-05-29T17:15:30+03:00"
  ["jpeg:colorspace"]=>
  string(1) "2"
  ["jpeg:sampling-factor"]=>
  string(11) "2x2,1x1,1x1"
}

$i->stripImage();

$p = $i->getImageProperties();
var_dump($p);
array(2) {
  ["jpeg:colorspace"]=>
  string(1) "2"
  ["jpeg:sampling-factor"]=>
  string(11) "2x2,1x1,1x1"
}

both have metadata ;)

All images which use any sort of compression contain metadata. Some are very modest, while other formats tell you more than you would ever need.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!