0

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.

IMSoP
  • 89,526
  • 13
  • 117
  • 169

1 Answers1

0

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.

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • Thank you for checking on the versions. I will download v 1.2.4 and hope that it fixes the problem. – user2250113 Feb 02 '21 at 21:34
  • @user2250113 As a general piece of advice, you should be regularly updating your libraries anyway (e.g. with `composer udpate`) in case they have security or other urgent fixes, and it's probably a good first step whenever you get an error in third-party code. – IMSoP Feb 02 '21 at 21:36
  • Upgrading to version 1.2.4 did the trick. In retrospect, it was kind of stupid of me not to think of updating the Imagine library. Thanks for taking the time to help. – user2250113 Feb 02 '21 at 21:40
  • Yes, totally useful. Just "accepted" the answer. – user2250113 Feb 02 '21 at 21:58