×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Dylan Lopez
Added: Mar 5, 2018 9:27 AM
Views: 2856
  1. $im = new imagick($local_original_image);
  2. $imageprops = $im->getImageGeometry();
  3. $width = $imageprops['width'];
  4. $height = $imageprops['height'];
  5. if($width > $height){
  6.     $newHeight = 80;
  7.     $newWidth = (80 / $height) * $width;
  8. }else{
  9.     $newWidth = 80;
  10.     $newHeight = (80 / $width) * $height;
  11. }
  12. $im->resizeImage($newWidth,$newHeight, imagick::FILTER_LANCZOS, 0.9, true);
  13. $im->cropImage (80,80,0,0);
  14. $im->writeImage( "cache/test.jpg" );