[Image-SIG] Re: Image-SIG digest, Vol 1 #273 - 1 msg

Kingsley kingsley@krt.com.au
Tue, 16 May 2000 06:11:19 +1000


 
> To summarize, I need to:
> - resize images of different sizes to (275, x)
> - generate the best quality I can
> 
> Basically, I'd like the thumbnail functionality with better output quality.
> I'm sure I'm simply not doing something correctly.  
> Perhaps a snipet of code would do me best.

Snippety-Snip

### Get some stats from the uploaded image
im = Image.open(pict_file_path)
pict_hires_x = im.size[0]
pict_hires_y = im.size[1]

###
### If the image is too big, resize it to 200x150ish
###
if pict_hires_x > 200 or pict_hires_y > 150:
    newx = 200
    newy = 150
    if pict_hires_x > pict_hires_y:
        newy = pict_hires_y * newx / pict_hires_x
    else:
        newx = pict_hires_x * newy / pict_hires_y
    im = im.resize((newx,newy),Image.BICUBIC)

im.save(thumb_filename,"JPEG",quality=50,optimize=1)

I think you should be able to just change the sizes and 
fire the sucker up.


cheers,
-kt


--
Kingsley Turner, mailto:kingsley@krt.com.au
Mad Dog's Breakfast:
    The Travel Magazine that doesn't take itself too seriously
    http://www.MadDogsBreakfast.com