Skip to content

Instantly share code, notes, and snippets.

@Djuki
Forked from ivanhoe011/cleanup.php
Created May 15, 2018 13:14
Show Gist options
  • Save Djuki/2f802ba40067d8759d19641a4dad71d4 to your computer and use it in GitHub Desktop.
Save Djuki/2f802ba40067d8759d19641a4dad71d4 to your computer and use it in GitHub Desktop.
Proper way to remove all metadata from an image
<?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