D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] mass image resizer

 

On Saturday 01 September 2007 10:11:34 Tom Potts wrote:
> Its java but may be of use to those who have requested info
> http://sourceforge.net/forum/forum.php?forum_id=730884
> Tom te tom te tom

The Python Image Library (PIL) is handy for this sort of thing:

#!/usr/bin/python

import sys
import Image

SIZE = 640

for index, path in enumerate(sys.argv[1:]):
    print "resizing", path
    image = Image.open(path)
    dx, dy = image.size
    scale = SIZE / float(max((dx, dy)))
    image = image.resize((int(dx * scale), int(dy * scale)))
    opath = "image_%03d.jpg" % index
    image.save(opath)

Cheers

Dave Berkeley

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html