Resizing of PIL images

T

Tuvas

I am seeking a way to resize a PIL image, even if the original is a
smaller dimention than the new size. Resizing seems to only make an
image smaller, and not larger. I have a 700x700 sized picture,
sometimes that will display an image larger and other times smaller. Is
there an easy way to do this, a command that I am missing from the
library? Thanks!
 
F

Fredrik Lundh

Tuvas said:
I am seeking a way to resize a PIL image, even if the original is a
smaller dimention than the new size. Resizing seems to only make an
image smaller, and not larger. I have a 700x700 sized picture,
sometimes that will display an image larger and other times smaller. Is
there an easy way to do this, a command that I am missing from the
library? Thanks!

newsize = (width, height)

im = im.resize(newsize)

</F>
 
P

Peter Hansen

Tuvas said:
I am seeking a way to resize a PIL image, even if the original is a
smaller dimention than the new size. Resizing seems to only make an
image smaller, and not larger. I have a 700x700 sized picture,
sometimes that will display an image larger and other times smaller. Is
there an easy way to do this, a command that I am missing from the
library? Thanks!

See the docs on transform(). From the sounds of it, if resize() won't
stretch something (it's own docs don't make that clear), then
transform() with appropriate arguments will.

-Peter
 
F

Fredrik Lundh

Peter said:
See the docs on transform(). From the sounds of it, if resize() won't
stretch something (it's own docs don't make that clear)

"resize" resizes the image to the given size.

"thumbnail" (which is an in-place operation) doesn't; it creates an
image no larger than the given size.

</F>
 
P

Peter Hansen

Fredrik said:
"resize" resizes the image to the given size.

"thumbnail" (which is an in-place operation) doesn't; it creates an
image no larger than the given size.

Ah... probably thumbnail() was what the OP was using when he referred to
resizing...
 
T

Tuvas

I used thumbnail originally, and am using resize now. Perhaps it has to
do with the image type (That is based on strings), but the resize
function just didn't do it for me. No idea why... Oh well, probably
just a problem for me, but, I've found a way around it, for the time
being.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top