Zerk Zone

Pages for the Creations of Ryan Armstrong

Image Gallery Script

Posted on October 11th, 2014 @ 9:45 am by Zerker

This is a script I wrote to generate an image gallery HTML file for a given folder, or for the Steam Screenshots folder. It will, by default, show the full resolution original image, so it can be useful for browsing a folder of moderate-sized images without having to rely on thumbnails. It can also generate thumbnails of any size if desired. Thumbnails are created into .thumb folders, which will be hidden in Unix-type OSes, but not (unfortunately) in Windows. Finally, the script can double-size and apply aspect ratio correction for smaller images (e.g. NES, SNES or DOS screenshots). These are sized using CSS attributes and do not generate a second copy of the image. Here’s an example gallery of X-Com screenshots with double-sizing and aspect ratio correction.

This can be run without any parameters to create the basic gallery in the current directory. For Windows users, you can also add a shortcut to the script in your SendTo folder to easily create a gallery for any folder by right clicking on it and using the SendTo menu.

usage: imagegallery.py [-w WIDTH] [-h HEIGHT] [-s] [-o OUTFILENAME] [-t] [-f] [-d] [-?] [imagefolder]
Creates a gallery of images.

positional arguments:

imagefolder
Image folder to generate a gallery for.

optional arguments:

-w WIDTH
Maximum thumbnail width. If not specified, width is not constrained
-h HEIGHT
Maximum thumbnail height. If not specified, height is not constrained
-s
Generates a Steam screenshot folder gallery with existing thumbnails
-o OUTFILENAME
Output gallery filename
-t
If set, surpresses titles for each subfolder
-f
If set, forces thumbnail regeneration. Otherwise, existing thumbnails will be used.
-d
If set, double-sizes small images (320×240 or lower). The image size is set via CSS to be resized by the web browser. Common resolutions of game screenshots (DOS, NES and SNES) are aspect-ratio corrected to 4:3. Not compatible with Steam mode.
-?, –help
Displays this help message and exits.

the script requires Python 3.x and ImageMagick, which also needs to be present on the System Path. The most basic function of the script (gallery without thumbnails or resizing) can be performed without ImageMagick if desired.

Download (2.2 kB)

Comments (0)

Filed under: Programs/Libraries,Python |

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment