django-resized
django-resized copied to clipboard
ImageQuality is Bad
So I have this original Image from pexels:
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
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
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?"
I have the same problem With full quality and high-quality Image I still get bad quality