Generate images with ImageMagick without saving to file but still display them on website

前端 未结 3 1368
长情又很酷
长情又很酷 2021-01-06 06:00

This is my ImageMagick code which works fine on my webserver by creating new image with the file name \'coloured_font.png\' in a default directory ...



        
3条回答
  •  逝去的感伤
    2021-01-06 06:54

    You will have to create a temporary file

    Steps

    1. Create a temporary file, temp_image.jpg by running imagemagick command in shell
    2. Send this as http response

      $file = 'pathto/temp_image.jpg';
      $type = 'image/jpeg';           // set appropriate type    
      header('Content-Type:'.$type);  // set content type
      header('Content-Length: ' . filesize($file));
      readfile($file);
      
    3. Delete temp_image.jpg

    Suppose this is in getImage.php, it can be given as the source of an image tag

    
    

提交回复
热议问题