PIL-resize, aspect ratio

Kevin Cazabon kevin_cazabon at hotmail.nospamplease!.com
Wed Mar 28 23:00:09 EST 2001


Unfortunately, the only way to "automatically" keep the aspect ratio is to
use the im.thumbnail(maxX, maxY) feature.  However, this uses NEAREST
resizing only.

Otherwise, you have to figure it out yourself, unfortunately.

However, I've asked Fred to add a "im.fit" method to PIL that I wrote a
while back that lets you resize, crop, etc. all at once.  He did at one
point say he was going to roll it into 1.1, however it would seem that it's
not in yet.

I've posted a zip of that stand-alone function, along with a separate module
that lets you rotate images an arbitrary amount, automatically adjusting the
canvas size to fit the entire rotated image (instead of cropping the output
to the input canvas size).

http://www.cazabon.com/python/downloads/PyImTools.zip


Fred:  any plans to incorporate these still?

Kevin Cazabon
kevin at cazabon.removethis.com





"Rikard Bosnjakovic" <bos at hack.org> wrote in message
news:3AC062B5.D5D0D471 at hack.org...
| Image.resize() takes a tuple with x,y when I resize, but how do I keep
| the aspect ratio? Do I need to calculate it on my own?
|
|
| --
| Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217
|
| Anyone sending unwanted advertising e-mail to my address will be
| charged $250 for network traffic and computing time. By extracting my
| address from this message or its header, you agree to these terms.





More information about the Python-list mailing list