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

ImageQuality is Bad #38

Open
yajm opened this issue Jun 25, 2021 · 1 comment
Open

ImageQuality is Bad #38

yajm opened this issue Jun 25, 2021 · 1 comment

Comments

@yajm
Copy link

yajm commented Jun 25, 2021

So I have this original Image from pexels:
4579551

But when I upload it to our Django model which is defined as:
picture640 = ResizedImageField(upload_to="influencer_profile640", null=True, blank=True, quality=80, size=[640, 640], crop=['middle', 'center'])
the image on the server then looks like
pexels-владимир-васильев-4579551

So I tired to reproduce this error locally. I achieved it by setting quality=0, but I haven't set the quality=0 in the model.

from PIL import Image, ImageOps

def square_image(img, size):
    img_width, img_height = img.size
    new_size = min(img_width, img_height)
    img = img.crop(((img_width - new_size) // 2, (img_height - new_size) // 2, (img_width + new_size) // 2, (img_height + new_size) // 2))
    new_image = img.resize((size, size), Image.ANTIALIAS)    
    return new_image
     
img = Image.open('original.jpg')
profile_image = square_image(img, 640)
profile_image.save('looks_how_it_is_supposed_to_look.jpg', optimize=True, quality=80)
profile_image.save('looks_the_same_as_on_the_server.jpg', optimize=True, quality=0)

This is the "looks_how_it_is_supposed_to_look.jpg" image
640
So my question is: "Why does it not use the attribute quality=80? And the quality of the image on the server is so bad?"

@AymanRefat
Copy link

I have the same problem With full quality and high-quality Image I still get bad quality

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

2 participants