简体   繁体   中英

Python Pillow Library full quality PNG resize

I'm trying to resize an image with the Python Pillow Library. My code is below.

        image = Image.open(io.BytesIO(image_request_result.content))
        image.thumbnail((200,2000), Image.ANTIALIAS)
        image.save(self.base + file_name + '.png',quality=95)

I want the width of the image to be 200 and the height to adjust to maintain the aspect ratio.

From other stackoverflow questions, it looks like the thumbnail method is the way to go. But, for some reason the images are not full quality.

When I re-size with GIMP, the file size is bigger and the image is not as pixelated. Thus, I think PIL is doing some type of compression.

I'm opening the image from a URL. I'm not sure if that makes a difference. I've looked at many other questions about re-sizing images, and they all seem to suggest the code I have right now. So, i'm not sure what i'm missing.

I wasn't able to solve this problem with the pillow library. But was able to get the outcome I expected using Wand with the transform function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM