readImage($url); }catch (ImagickException $e){ $image->readImage("/home/hebergement/tcrouzet-lab/pandoc/dead.jpg"); } $image->setImageResolution(300,300); $type=$image->identifyImage(); //print_r($type);exit; $w = $image->getImageWidth(); if($w<500){ $h = $image->getImageHeight(); $image->resizeImage($w*3, $h*3, Imagick::FILTER_LANCZOS, 0.9); }elseif($w<800){ $h = $image->getImageHeight(); $image->resizeImage($w*2, $h*2, Imagick::FILTER_LANCZOS, 0.9); } //$image->setImageColorspace(Imagick::COLORSPACE_GRAY); $image->transformImageColorspace(Imagick::COLORSPACE_GRAY); //$type['format']=""; if(strpos($type['format'],"PNG")!==false){ $image->setImageFormat("png"); header("Content-type: image/png"); }elseif(strpos($type['format'],"GIF")!==false){ $image->setImageFormat("gif"); header("Content-type: image/gif"); }else{ $image->setImageFormat('jpeg'); $image->setImageCompression(Imagick::COMPRESSION_JPEG); $image->setImageCompressionQuality(80); header("Content-type: image/jpg"); } echo $image->getImageBlob(); $image->clear(); ?>