coalesceImages(); do { $image->cropthumbnailimage(150, 150); } while ($image->nextImage()); $image->writeImage($newFile.'.jpg'); $img->destroy(); */ /* // Uncaught ImagickException: NoDecodeDelegateForThisImageFormat `JPEG' $thumb = new Imagick($file); $thumb->resizeImage(320,240,Imagick::FILTER_LANCZOS,1); $thumb->writeImage('mythumb.jpg'); $thumb->destroy(); */ $outFile = "test-cropped.jpg"; // resize if necessary $thumb_w = 300; $thumb_h = 300; // File type #header('Content-Type: image/jpg'); list($origin_w, $origin_h) = getimagesize($file); $origin_ratio = round($origin_w / $origin_h, 1); /**/ // check if the file is really an image if ($origin_w == null && $origin_h == null) { #header("Location: index.php"); #return; echo "No file !"; } if ($thumb_w / $thumb_h > $origin_ratio) { $thumb_w = $thumb_h * $origin_ratio; } else { $thumb_h = $thumb_w / $origin_ratio; } if ($origin_w >= 400 && $origin_h >= 400) { $image = new Imagick($file); // !!! $image->thumbnailImage($thumb_w, $thumb_h); $image->writeImage($outFile); $image->destroy(); } ?>