setImageFormat('jpeg'); $imagick->setImageCompression(Imagick::COMPRESSION_JPEG); $imagick->setImageCompressionQuality($quality); $imagick->cropThumbnailImage($width, $height); $imagick->setImagePage(0, 0, 0, 0); if (file_put_contents($thumb, $imagick) === false) { throw new Exception("Could not put contents."); } return true; } else { throw new Exception("No valid image provided with {$img}."); } ?>