-
-
Save Djuki/2f802ba40067d8759d19641a4dad71d4 to your computer and use it in GitHub Desktop.
Proper way to remove all metadata from an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$img = new Imagick($img); | |
// code by Max Eremin http://php.net/manual/en/imagick.stripimage.php#120380 | |
// we need to keep the ICC profiles | |
$profiles = $img->getImageProfiles('icc', true); | |
// but remove everything else | |
$img->stripImage(); | |
// re-attach the color profiles | |
if ( ! empty($profiles)) { | |
$img->profileImage('icc', $profiles['icc']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment