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

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:14:01

问题


Privacy concerns have lead me to believe I should scrub user uploaded images for any meta data.

I know that JPEG have EXIF, but I'm not sure about PNG or GIF (both are able to be uploaded to my site from the public).

Do these formats have meta data too, and how is it stored? What is the best way to remove it?

I'm using PHP 5.29.

Thanks


回答1:


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.




回答2:


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"
}



回答3:


both have metadata ;)




回答4:


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.



来源:https://stackoverflow.com/questions/3645451/which-image-formats-contain-meta-data-and-how-can-i-clear-it-in-php

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