Skip to content

Instantly share code, notes, and snippets.

@bmoore
Last active December 18, 2015 19:18
Show Gist options
  • Save bmoore/5831578 to your computer and use it in GitHub Desktop.
Save bmoore/5831578 to your computer and use it in GitHub Desktop.
Imagick resize
<?php
$x = $y = 0;
$image = new Imagick('orig.jpg');
//get_smallest_dimension
if ($image->getImageWidth() < $image->getImageHeight()) {
$x = 612;
} else {
$y = 612;
}
$image->thumbnailImage($x, $y);
//grab extension first for filename
file_put_contents('/tmp/newimg.jpg', $image->getImageBlob());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment