Bw parameter in thumbnails?

Hi,

Can I apply a black and white filter on thumbnail? I have ->thumb(['width' => 748, 'height' => 520, 'crop' => true, 'blur' => 80, 'bw' => true]) the blur is working but not the black and white parameter. I can’t find the proper syntax or exemple of complete thumbs parameters anywhere :frowning:

I wan to apply the filter on the thumbnail because I assume it’s less ressource-consuming but i’m not sure.

thanks!

The option is called grayscale.

oh yes, thank you! Can’t find the doc so I assume it was the same parameter than b&w images.

For the record, an exemple is shown here : https://getkirby.com/docs/cheatsheet/helpers/thumb (with old but functional thumb syntax)
also here: https://getkirby.com/docs/developer-guide/configuration/thumbnails

I used: ->thumb(['width' => 748, 'height' => 520, 'crop' => true, 'grayscale' => true, 'blur' => 80])->url();

<?php  echo thumb($page->image(), ['width' => 748, 'height' => 520, 'crop' => true, 'blur' => 80, 'grayscale' => true]) ?>

last question : when I change the blur amount, nothing change (no cache activated) are the thumb cached automatically?

(maybe I use invalid blur values)

Edit: Hm, the docs only have blur true, but I thought that some sort of value was introduced lately.

Edit2: https://github.com/getkirby/kirby/issues/437

yep, after some tests and thumb deletion, it seems that the blur is always the same ^^
Let me know if it can take parameters someday! (or I blur the image but it’s big so I fear for the performance)

Edit: Blur the file beforehand do nothing : $imagefile->blur(100)->thumb(['width' => 748, 'height' => 520, 'crop' => true, 'grayscale' => true, 'blur' => 10])

Edit2: maybe the image was too big to be blurred (timeout)

Not sure, but somehow it does not seem to be possible to blur and resize by stringing those methods (error that a thumb cannot be further modified). Apart from that, if you try to resize a big image, you indeed easily run into a timeout, if max_execution_time is too short.

If you need this functionality, you could set up your own thumbs driver that implements a blur degree.

also, I have to test it further, but it seems that on large images (or extreme ratio) the thumb crop output wrong size of thumbnail.

'blur' => true, 'blurpx' => 10

1 Like