PHP-Imagemagick image display

后端 未结 7 816
猫巷女王i
猫巷女王i 2020-12-05 20:36

I have php code which create pdf thumbnail as follows;

setImageFormat(\"png         


        
7条回答
  •  [愿得一人]
    2020-12-05 21:14

    In my case I found out a solution like this:

                $im = new Imagick("http://www.yourserver.com/upload/file_name.pdf");
                $im->setResolution(300, 300);     // if higher image will be good to read
                $im->setIteratorIndex(0); // read first page
                $im->setImageFormat('jpg');
                header('Content-Type: image/jpeg');
    
                ob_start();
                print $im->getImageBlob(); 
                $contents =  ob_get_contents();
                ob_end_clean();
    
                echo ""; //output as image
    

    good luck.

提交回复
热议问题