escpos-php icon indicating copy to clipboard operation
escpos-php copied to clipboard

PHP 8.0 GdEscposImage::readImageFromGdResource($im) Failed to load image.

Open osiams opened this issue 4 years ago • 4 comments

PHP 8.0: GdImage class objects replace GD image resources.

This works for me.

if (!is_resource($im) && !is_object($im)) { throw new Exception("Failed to load image."); } ...... .................

osiams avatar Dec 16 '20 20:12 osiams

Hi!

We need this commit to get into master and be able to use it via composer. I see the build failed, but I guess it's an false positive?

adydeac avatar Jan 21 '21 21:01 adydeac

Bug is GdEscposImage:61

if (!is_resource($im)) { throw new Exception("Failed to load image."); ... Why not is a resource?

joseantoniopino avatar Jun 10 '21 14:06 joseantoniopino

Please repair bug in php 8

nGincode avatar Dec 10 '21 13:12 nGincode

If anyone else is using PHP8, and is getting this error, I would recommend to reference directly to the development branch, because this error is already resolved in the PR https://github.com/mike42/escpos-php/pull/1042

The easy way to do this would be to just execute the following lines:

composer remove mike42/escpos-php --update-with-dependencies
composer require mike42/escpos-php:dev-development

Note: This is actually not recommended, because referencing a branch in active development can be unreliable, and yield different results in CI pipelines, but, is useful if you need a quick solution,

If you want a little bit more of stability, you can reference the specific commit:

# Instead of
composer require mike42/escpos-php:dev-development
# Do
composer require mike42/escpos-php:dev-development#f414320fc510afcacd4cbb75902f827399dee429

thblckjkr avatar Feb 07 '22 07:02 thblckjkr