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
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.
来源:https://stackoverflow.com/questions/3645451/which-image-formats-contain-meta-data-and-how-can-i-clear-it-in-php