PHP-Imagemagick image display

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

I have php code which create pdf thumbnail as follows;

setImageFormat(\"png         


        
7条回答
  •  死守一世寂寞
    2020-12-05 21:23

    Embedding an image using base64 is a COMPLETELY wrong way to go about the problem esp. with something stateless like a php web script.

    You should instead use http parameters to have a single php file which can perform two tasks - the default will send html , and the parameter will instruct the php file to print the image. Below is the "standard" way to do it -

    ');
    } else
    {
        // The display key exists which means we want to display an image
        $file ="test.pdf";
        $im = new imagick(realpath($file).'[0]');
        $im->setImageFormat("png");
        $im->resizeImage(200,200,1,0);
        header("Content-Type: image/jpeg");
        $thumbnail = $im->getImageBlob();
        echo $thumbnail;
    }
    ?>
    

提交回复
热议问题