In Python's PIL, how do I change the quality of an image?

I want to degrade the quality of the image to a few kilobytes. What's the best way to do this?

Thanks!

Answers


If the picture format is JPEG, here's an example:

from PIL import Image
im = Image.open("C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg")
im.save("C:\Users\Public\Pictures\Sample Pictures\Jellyfish_compressed.jpg", quality=10)

The references you need to be reading are:

  • [The Image module][1], particularly the "save" function, which allows you to pass in options relevant for each image format.
    • Each image format's options are in a different page, you can find it in the docs.

Need Your Help

Difference between $(this) and $(“#id”) in a each loop in jquery

javascript jquery jquery-selectors

I'm new to jquery. I know the question is stupid but I'm missing some concept here.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.