You cannot chain multiple thumb methods. To apply multiple options, use the thumb method with an array of options: $image->thumb(['width' => 250, 'grayscale' => true])
The option for black&white images is called grayscale (not greyscale or bw)
I can’t see any examples where chaining with resize/crop etc is used? Of course you can call $image->greyscale() on an image, but not on a fileversion object.
Infact neither ‘greyscale’ or ‘bw’ seem to work with ImageMagick, only ‘grayscale’ does. It does append bw on to the end of the filename though, but it remains full color.
hmm, strange, im using GD as the driver and I also can only use “grayscale” … both greyscale and bw don’t seem to work. Using those leave the image thumbs coloured.
Hmm… interesting I had a poke around in source code and couldnt see any evidence that you can use any of those three, only grayscale seemed to be in there.
/**
* Converts the image to black and white
*
* @return \Kirby\Cms\FileVersion|\Kirby\Cms\File
*/
public function bw()
{
return $this->thumb(['grayscale' => true]);
}
Your’e right James. It would however make sense that thumb() also has access to it, as it has access to other functions like blur(). Why restrict bw() or greyscale() to the file method only?
It is to do with the way some operations on images happen. Once the file becomes a file version, you can’t do further mods to since its now in the media folder. blur, greyscale and bw are all one trick methods, and they call thumb() them selves on the image. In otherwords you cant chain thumb() twice on an image, which is basically what is happening when you do $image->thumb('300')->bw()
thumb() allows you to bundle up a few things (width, height, quality, greyscale etc) in one pass to get around this.
I found that if you run one, then switch it and thumb is already in the media folder, it doesnt do it. I had to delete my media folder each time to see the difference between the 3 wordings. Maybe you already had a thumb that stopped it working further, and made it look like it had worked. I think if the source image had changed (like you had replaced the image with a different version of it), it would created a fresh thumb. It uses hashing doesnt it, so it doesnt update the thumb unless the hash has changed.