I just came across a weird imagescaling artifact after upgrading a Plone 5.0 instance to 5.1 (don't ask).
What I noticed first was that some "thumb 128:128" scales looked dithered and some did not. I compared the Pillow versions, re-uploaded the original images and saw that the scale had been regenerated, tried saving different PNG variations of the original - all with the same result.
In the meantime, I noticed that the same image at a higher scale would be 24 bit. I fiddled with the scale settings in the control panel. My conclusion is that depending of the scale size, a threshold is reached and a choice for palette or 24 bit is made somewhere. This varies per image.
Here two scales of the same original: respectively 293 and 294 pixels wide. Where should I look to remove this over-optimization?
While at it, I will also check what happens on the latest Plone 6 and report back...
Edit: when I write the patch in the original, the affected imaged do not render at all. Which is good because it gives me a direction to search further...
I suspect that this issue concerns only PNG images that were saved with some specific settings. I looked at the two types of images in GIMP and with command line tools - Could not discover a difference.
Update: I was able to patch plone.scale scale.py by using the method described here:
This required the __init__ module of my package to include:
from plone.scale import scale
from .patches.plone_scale_scale import own_scaleImage
scale.scaleImage = own_scaleImage
It was apparently not sufficient to have this in the patch itself, as was done in the eea package.
Now that I have the scaling working again, I would like to nuke the old scales. The method I used to regenerate scales while testing was to change the sizes of the "thumb" scale in the control panel. This approach on the production site results in re-using the cached scale.
What seems to work is to re-save the image, but this is something I'd rather avoid doing. I "think" I remember having seen a control panel view that takes care of clearing cached scales, but maybe I dreamt it