Zend_Pdf_Image::imageWithPath from URL

前端 未结 1 1919
粉色の甜心
粉色の甜心 2021-01-22 21:49

I\'m using a script that generates a PNG image based on a URL parameter image_id. For example: http://www.example.com/image.php?image_id=G554jGTT

1条回答
  •  温柔的废话
    2021-01-22 22:01

    You cannot do this using Zend_Pdf_Image::imageWithPath. The reason is that the ImageFacotry expects a file. And it uses is_file method to check if file exists. However, is_file function does not necessarily work with remote files.

    One way to overcome this problem would be to download the image and save it under temporary name, and this temporary file then put into Zend_Pdf_Image::imageWithPath. To download and save the file, you could use, e.g. file_put_contents('./tempname',file_get_contents($imagepath)). Off course, the tempname should be random and it should be removed afterwards.

    0 讨论(0)
提交回复
热议问题