django-resized icon indicating copy to clipboard operation
django-resized copied to clipboard

ImageQuality is Bad

Open yajm opened this issue 3 years ago • 1 comments

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?"

yajm avatar Jun 25 '21 10:06 yajm

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

AymanRefat avatar Jun 06 '22 11:06 AymanRefat