elpendor / ES-scraper

A scraper for EmulationStation
47 stars 41 forks source link

Optional Argument for specifying max height #23

Open j4c3 opened 11 years ago

j4c3 commented 11 years ago

I see -h is taken, but it seems like it might be useful the have the option to specify a max height. Screens tend to be wider than tall, so I'd like to keep the height of all boxes the same, and let the width vary. This also allows for a more constant length the description can be across systems.

Spitz4478 commented 10 years ago

I've never written anything in python, but it seems like an easy enough task. Untested code below:

After the following code...

parser.add_argument("-w", metavar="value", help="defines a maximum width (in pixels) for boxarts (anything above that will be resized to that value)", type=int)

Add this (l was an arbitrary choice since h is taken; it could be anything you like, really)...

parser.add_argument("-l", metavar="value", help="defines a maximum height (in pixels) for boxarts (anything above that will be resized to that value)", type=int)

Then further down in the script, after the following code...

maxWidth= args.w
    if (img.size[0]>maxWidth):
        print "Boxart over %spx. Resizing boxart.." % maxWidth
        height = int((float(img.size[1])*float(maxWidth/float(img.size[0]))))
        img.resize((maxWidth,height), Image.ANTIALIAS).save(output)

add this...

maxHeight= args.l
    if (img.size[1]>maxHeight):
        print "Boxart over %spx. Resizing boxart.." % maxHeight
        width = int((float(img.size[0])*float(maxHeight/float(img.size[1]))))
        img.resize((width,maxHeight), Image.ANTIALIAS).save(output)