Skip to content

Instantly share code, notes, and snippets.

@bytehead
Last active May 10, 2019 20:41
Show Gist options
  • Save bytehead/5917952 to your computer and use it in GitHub Desktop.
Save bytehead/5917952 to your computer and use it in GitHub Desktop.
imagick pdf to jpg
<?php
// read page 1
$im = new imagick( 'test.pdf[ 0]' );
// convert to jpg
$im->setImageColorspace(255);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(60);
$im->setImageFormat('jpeg');
//resize
$im->resizeImage(290, 375, imagick::FILTER_LANCZOS, 1);
//write image on server
$im->writeImage('thumb.jpg');
$im->clear();
$im->destroy();
@mindylynn0
Copy link

@workeywebworks
Copy link

This doesn't work on latest version of ghostscript. Any help is pretty much appreciated

@bobmagicii
Copy link

This doesn't work on latest version of ghostscript. Any help is pretty much appreciated

i uninstalled ghostscript 9.27 and installed 9.26 and got pdf converting to work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment