D
D
danij_com2017-06-26 20:29:23
Regular Expressions
danij_com, 2017-06-26 20:29:23

How to proportionally fit the size of a pil image?

We need to proportionally zoom the image so that it is no more than 99 pixels wide and 99 pixels high. How to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2018-12-01
@anttoon

found -
r'"(\w+[\s*\w*]*)"'

L
longclaps, 2017-06-26
@danij_com

from PIL import Image

im = Image.open("original.png")
h, w = im.size
scale = 99 / max(h, w)
im.resize((int(h * scale), int(w * scale)), Image.ANTIALIAS).save("resized.png")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question