views:

500

answers:

3

When I call resize on images using app engine, they maintain their aspect ratio - I don't end up with the size I ask for.

I'm trying to make rectangular pixel NTSC images from square pixel sources, so I don't want this behaviour

I want to take an image that is 720x540 and resize it to 720x480 but what I actually end up when ask for the resize is an image that is 640x480.

Is there any way round this?

+1  A: 

Are you giving the resize method both a width and a height?

http://code.google.com/appengine/docs/python/images/functions.html

Jason Hall
Yes I am. #These characters to beat the comment minimum :)
Gareth Simpson
A: 

Why not use the crop function?

The correct arguments to transform a 720x540 to a 720x480 image would be (presuming you want a center crop):

crop(bytestream, 0, 0.055, 1, 0.945, output)

The crop function takes its arguments as a proportion of the image width or height, specified as a float value from 0.0 to 1.0.

jason
I don't need a crop, I need to rescale it.
Gareth Simpson
How can you rescale an image on only the y-axis? You can't scale without ruining the aspect ratio. If you want to resize, sure, you can squish the image if you'd really like.
jason
I want to ruin the aspect ratio. These are images for insertion into videos that will be displayed on NTSC TVs. NTSC TVs have rectangular pixels. So when you make an image on a square pixel computer you have to squish it in the Y axis so that when it's displayed with rectangular pixels it stretches back out again and looks the same as the original. PAL is the same but you squish the X axis.http://docs.info.apple.com/article.html?artnum=36836
Gareth Simpson
+2  A: 

Alas, while PIL per se could do it, that's not what App Engine's very simple images functionality is using (you may be confused by the fact that the SDK is indeed using PIL to implement that functionality's API on your development machine) -- in particular, resize always does respect the aspect ratio. Your chance to get higher functionality depends on asking for it on app engine's issue tracker, and hoping that many developers have that need!

Alex Martelli
I thought as much, ah well.
Gareth Simpson