SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.37k stars 312 forks source link

How to force a single field to convert the thumbails to JPG even if PNG with alpha was provided #615

Open adrenaline681 opened 1 year ago

adrenaline681 commented 1 year ago

I'm aware that you can globally configure for all images (even PNGs with alpha) to be converted to JPG by adding this to your settings.py

THUMBNAIL_TRANSPARENCY_EXTENSION = 'jpg'

But the problem is that I don't want to force ALL of my images in all the models to be converted to JPG because I have some models that require images with alpha (png).

What I want is to force a single field in a single model to convert to JPG all images no matter if they are PNGs with alpha enabled.

class Article(BaseModel):
    title = models.CharField(max_length=255, unique=True)
    image = ThumbnailerImageField(upload_to='blog/articles/image')

I want this because many people are uploading PNG's with alpha enabled and this is preventing the Thumbnailer to compress them as JPG making many of the thumbnails remain as PNG's (500kb) instead of being converted to JPG (70kb).

How can I specify to always convert these article images to JPG?