Skip to content

Instantly share code, notes, and snippets.

@pthiers
Last active August 29, 2015 14:17
Show Gist options
  • Save pthiers/b424eab9e43b11e6d00c to your computer and use it in GitHub Desktop.
Save pthiers/b424eab9e43b11e6d00c to your computer and use it in GitHub Desktop.
Imagick: tiff to PNG8
<?php
header('Content-type: image/png');
$image = "/var/www/html/images/image.TIFF";
$im = new Imagick($image);
// resize by 500 width and keep the ratio
$im->thumbnailImage(500, 0);
//Set new image format 'PNG8'
$im->setImageFormat("PNG8");
//Get the min colors of the image.
$colors =min(255,$im->getImageColors());
$im->quantizeImage($colors,Imagick::COLORSPACE_RGB,0,false,false);
$im->setImageDepth(8);
echo $im;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment