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
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"
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With