Getting error when using Imagine with Xampp PHP 8.0.1

258 views Asked by At

When using the Imagine library with Xampp PHP 8.0.1, I'm getting an error with the open() function in the file Imagine/Gd/Imagine.php. Specifically, line #93 of code:

$resource = @imagecreatefromstring($data);

The returned value of $resource is {GdImage}[0] and is not a resource which then throws an error.

If I simply go back to Xampp PHP 7.4.13, everything is fine.

Any thoughts would be appreciated.

1

There are 1 answers

4
IMSoP On BEST ANSWER

I just tracked back, and the last time that code was on line 93 (well, 92 according to github) was v1.2.1 released in June 2019. That's before even PHP 7.4 was released, so you shouldn't be surprised it doesn't contain PHP 8 compatibility fixes.

Version 1.2.4 came out in November promising PHP 8 support, which is actually very prompt after the release!

As background for why it needed fixing (and why your code might too), resources have been replaced by GdImage objects in PHP 8.0, as part of a longer term project to phase out resources from the language.