php-imagine / Imagine

PHP Object Oriented image manipulation library
https://imagine.readthedocs.io
Other
4.42k stars 530 forks source link

A possible workaround for issue #859 #860

Closed jcogs-design closed 1 month ago

jcogs-design commented 1 month ago

This provides a slightly more tolerant response to allow_url_fopen being closed on a server than throwing an exception and baling out.

The proposed approach still traps for the status of the allow_url_fopen option, and if it is available uses the prior data:// method. If it is not available, and the source image is not a Tiff file, it writes a low quality version of the image to a temporary file on disk, and uses this as the target for exif_read_data() and then once data is read deletes the temporary file.

The code works in testing here.

Note, this approach is a demonstration of an alternative approach rather than a proposal for a definitive solution, in that it uses GD2 functions and so does not handle Tiff images. But presumably if the concept is viable the code could be generalised to work with any of the image libraries supported by Imagine.

I'm not so familiar with automated testing, so not able to provide a test for this change. Apologies.

mlocati commented 1 month ago

I prefer the approach of #861