PHP100 2019-03-27
代码如下:
function pdf2png($pdf, $filename, $page=0) { if (!extension_loaded('imagick')) { exit('no imagick'); return false; } if (!file_exists($pdf)) { return false; } $im = new Imagick(); $im->setResolution(120, 120); $im->setCompressionQuality(100); $im->readImage($pdf . "[" . $page . "]"); $im->setImageFormat('png'); $im->writeImage($filename); $im->readImage($filename); $im->resizeImage(120, 150, Imagick::FILTER_LANCZOS, 1); $im->writeImage($filename); return $filename; }