Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adrenaline681 opened this issue Mar 16, 2023 · 0 comments

Comments

@adrenaline681
Copy link

adrenaline681 commented Mar 16, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant