Image thumbnail with width set to 1 results in error


#1

I’m not sure this is actually a bug, but I was playing around with some things, and found that the following line results in an error:

<?= $image->thumb(array('width' => 1)); ?>

The error I get is:

Whoops\Exception\ErrorException thrown with message "get_resource_type() expects parameter 1 to be resource, boolean given"

Stacktrace:
#18 Whoops\Exception\ErrorException in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/vendors/abeautifulsite/SimpleImage.php:57
#17 get_resource_type in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/vendors/abeautifulsite/SimpleImage.php:57
#16 abeautifulsite\SimpleImage:__destruct in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/lib/thumb.php:361
#15 {closure} in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/lib/thumb.php:224
#14 Thumb:create in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/lib/thumb.php:77
#13 Thumb:__construct in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby/component/thumb.php:85
#12 Kirby\Component\Thumb:create in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby/traits/image.php:46
#11 FileAbstract:thumb in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/site/snippets/article.php:16
#10 require in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/lib/tpl.php:22
#9 Tpl:load in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby/component/snippet.php:38
#8 Kirby\Component\Snippet:render in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/helpers.php:12
#7 snippet in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/site/templates/home.php:20
#6 require in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/vendor/getkirby/toolkit/lib/tpl.php:22
#5 Tpl:load in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby/component/template.php:103
#4 Kirby\Component\Template:render in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby.php:635
#3 Kirby:template in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby.php:623
#2 Kirby:render in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby/component/response.php:29
#1 Kirby\Component\Response:make in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/kirby/kirby.php:705
#0 Kirby:launch in /Users/robin/Dropbox/work/2017-01-02_DAVL_website/kirby/index.php:16

This is my article snippet.

It seems to happen for other 1-digit widths as well. I guess they are interpreted as booleans?


#2

I can’t reproduce this, does the same image work with other settings?


#3

Hi @texnixe, sorry for the late reply. It works with any two-digit width. You can see for yourself with this repo.


#4

Unfortunately, the content is missing from the repo so I can’t really test with your version. However, I copied your code from the gist into a template and the code worked in that installation without any problem.

Maybe you can provide more information. What is your PHP version? Are you using gd lib or imagemagick?


#5

Ah, right. I can send you (some of) the content if you’d like to test.

Right now I’m only serving the site locally with MAMP. PHP version is 7.1.8 and I’ve not made any changes to anything related to images, so I don’t think I’m using imagemagick, but I’m not sure what the standard is with MAMP.


#6

Hm, I also tested this with Mamp (PHP 7.1.5) and can’t reproduce this with my test image.