Skip to content
Advertisement

imagesx() expects parameter 1 to be resource, boolean given

I am using a image thumbnailing library (Laravel’s resizer bundle) which takes a jpg from a directory and uses imagesx() to save that image in a different size. This works without error most of the time.

Problem: However sometimes when there is a batch of images to be processed, I get the error below. While debugging, I did

JavaScript

PHP output

JavaScript

Together with the stack trace above, you can see that $this->image is false right after its Resource id #166.

Any idea what may have caused this? I dont understand why it can sometimes be false. Thanks!

Advertisement

Answer

This is happening because the mime type for that file isn’t being recognised or is not a jpg/jpeg/png/gif.

The $this->image is being set to false on line 196 in resizer.php.

If you can’t get it to work, please create an issue on Github so I can follow it up 🙂

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement