Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 598 Bytes

how-to-set-jpg-quality-on-save.md

File metadata and controls

18 lines (12 loc) · 598 Bytes

How to set JPG quality on save

from PIL import Image, ImageDraw, ImageFont

im = Image.open('/var/www/examples/heroine.png')
im.save('out.jpg', quality=95)
  • PIL - import lib:Pillow package modules
  • Image.open - open given image with Pillow
  • .save( - saves image under given path (format is automatically picked based on file extension)
  • quality - sets JPG quality value
  • 95 - quality value to use (where 100 is the best quality while lower values = worse quality)

group: compress