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) { log_error("Could not put contents."); } }catch(Exception $exception){ log_error($exception); $imagick = file_get_contents($img); } header("Content-type: image/jpeg"); echo $imagick; exit; } else { log_error("No valid image provided with {$img}."); } ?>