humanmade / WPThumb

:warning: UNMAINTAINED :warning: On demand image resizing for WordPress
https://humanmade.co.uk/wpthumb/
170 stars 32 forks source link

imagecolorallocatealpha() expects parameter 2 to be long, string given #82

Open mecha opened 11 years ago

mecha commented 11 years ago

We keep getting a bunch of these warnings every now and then. They come and go randomly.

The source of the warning is wpthumb.background-fill.php, lines #62 - #86.

Using line #64 as an example, I think the parameters that are in the form substr( $colors['left'], 0, 3 ) need to be casted to a long value.

According to the PHP Manual comments, a simple solution to do this without getting bit overflow is by simply adding zero.

substr( $colors['left'], 0, 3 ) + 0

Regards :)

joehoyle commented 11 years ago

Thanks @mekku93 I think maybe is failing to get the colors, which would explain the intermittent nature. Can you upload the image that produces this warning of alternatively email joe hoyle at gmail dot com

mecha commented 11 years ago

There is no particular image. We are using it with a plugin that fetches images from various sources.

This warning appears for various images but as I said, it shows randomly and it may work for a particular image at one moment, and fail on refresh.

( I think it is worth noting that the image is still displayed properly, even though this warning is shown. )

jgalea commented 11 years ago

Same thing, when rendering images via WPThumb, I sometimes get these warnings:

Warning: imagecolorallocatealpha() expects parameter 2 to be long, string given in ....WPThumb/wpthumb.background-fill.php on line 76

Try this code, it happens on my local installation. You probably need to set WP_DEBUG to true to see these warnings:

echo '<img src="' . wpthumb( 'http://s8.postimg.org/l0pouom41/image.jpg', 'width=500&height=500&crop=1&background_fill=solid' ) .'"" />

jgalea commented 11 years ago

See https://github.com/humanmade/WPThumb/pull/89