mezzanine icon indicating copy to clipboard operation
mezzanine copied to clipboard

JPEG Handling changes in PIL/Pillow

Open zandeez opened this issue 8 years ago • 7 comments

Resolves the following:

  • JPEG images cannot be saved as RGBA
  • JPEG images may still be of a mode that we want to convert from
  • Padded images are always created RGBA which breaks JPEG

zandeez avatar Sep 18 '17 19:09 zandeez

I'm able to successfully generate thumbnails for jpegs without this change, can you provide more info on how to reproduce the problem?

stephenmcd avatar Apr 11 '18 01:04 stephenmcd

Hi Stephen,

It looks like padded thumbnails are affected in particular.

{% thumbnail product.image 350 350 True 95 0.5 0.5 True "white" %}

Currently doesn't seem to generate a thumbnail, but does with the changes.

Thanks,

zandeez avatar May 11 '18 20:05 zandeez

I still can't reproduce the problem. I used the vars you specified for the thumbnail tag and I get a valid resized image, see:

screen shot 2018-05-15 at 11 42 04 am

stephenmcd avatar May 15 '18 01:05 stephenmcd

If I remember correctly, the problem zandeez is describing occurs with newer versions of PIL/pillow.

viaregio avatar May 30 '18 09:05 viaregio

Seems to be resolved Mezzanine 4.3.1, Pillow 5.3.0

zandeez avatar Nov 09 '18 21:11 zandeez

Spoke too soon, it's not generating thumbnails for me from JPEG, even with this patch.

Python 3.6.7 Mezzanine 4.3.1 Pillow 5.3.0

zandeez avatar Nov 09 '18 21:11 zandeez

Ignore me, the patch does work I hadn't applied it correctly.

Basically with the versions listed above, if thumbnailing with padding with a format that doesn't support RGBA (such as jpg) the thumbnail will not save. This patch forces jpegs to be RGB rather than RGBA which saves consistently.

zandeez avatar Nov 09 '18 21:11 zandeez