compress image pillow 1

compress image pillow

from PIL import Image
b = Book.objects.get(title='Into the wild')
image =,quality=20,optimize=True)

Here is what the above code is Doing:
1. We are getting the book object from the database.
2. We are opening the image file using the method.
3. We are saving the image file using the method.
4. We are passing the path of the image file as the first argument.
5. We are passing the quality of the image as the second argument.
6. We are passing the optimize flag as the third argument.

The quality of the image is set to 20.
The optimize flag is set to True.

Similar Posts