endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.46k stars 728 forks source link

PHP 8 - PngWriter throw a GenerateImageException #287

Closed webdreamsCH closed 3 years ago

webdreamsCH commented 3 years ago

Hi, under PHP 8.0.0 the check is_resource($image) fails.

until php 7.4. the type was resource(91) of type (gd) under php 8 type is now a object GdImage

many thanks for the customization in source

endroid commented 3 years ago

Hi @webdreamsCH you're right. PHP 8.0 is not supported yet as one of the dependencies is not yet PHP 8 compatible. Subscribe to https://github.com/khanamiryan/php-qrcode-detector-decoder/pull/103 if you want to know when support is added. As soon as this works I will update and tag.

hrvoj3e commented 3 years ago

Maybe add this note about PHP8 to readme?

Btw. this works OK for PNGs in my setup (lines: 73 and 96)

if (!is_resource($image) && !is_object($image)) {
    throw new GenerateImageException('Unable to generate image: check your GD installation');
}
endroid commented 3 years ago

In the new 4.0.0 version which is PHP 8.0 compatible both resource and GdImage are supported.

kohlerdominik commented 3 years ago

@endroid Looks like khanamiryan/php-qrcode-detector-decoder#103 just got merged 👍

Will you make a 3.x release with the fix?

endroid commented 3 years ago

@kohlerdominik nice, I updated the requirement and tagged the new version ;)