PHP-Imagemagick image display

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

I have php code which create pdf thumbnail as follows;

setImageFormat(\"png         


        
7条回答
  •  春和景丽
    2020-12-05 21:05

    As I can see there are too many answers which are not accurate enough, so here goes mine:

    This will print the image as you are doing it now(by the time of asking this question). As alternative to answer by @Vasil Dakov you should modify the snippet i gave you like this:

    getImageBlob();
    $the_outputted_image = ob_get_flush();
    ?>
    // Assuming that you use MVC approach and you are storing $the_outputted_image in a object and passing it to the view(ie. index.html or the HTML below the code).
    //... Html code of index.html
    image
    

    As another alternative is creating a script to generate the image, save it in some folder ( assuming img/ is the folder) and return only the path+filename+ extension to the file:

    writeImageFile($fp); //Writing the image to the file pointer (I would recommend writing it using, fwrite(), because it is binary-safe writing method)
    fclose($fp);
    ?>
    
    // Html
    image
    

    documentation for Imagick::writeImageFile

提交回复
热议问题