Created
March 3, 2019 02:17
-
-
Save xiwcx/6397cc2112615d5556f9b5e4616b53ab to your computer and use it in GitHub Desktop.
pillow examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
from PIL import Image, ImageOps | |
infile = "example.jpg" | |
square = os.path.splitext(infile)[0] + ".square.jpg" | |
webp = os.path.splitext(infile)[0] + ".webp" | |
size = (1000, 1000) | |
im = Image.open(infile) | |
square_image = ImageOps.fit(im, size, Image.ANTIALIAS) | |
square_image = square_image.convert(mode="RGB") | |
webp_image = im; | |
square_image.save(square, quality=70, optimize=True, progressive=True) | |
webp_image.save(webp, quality=70, method=6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment