Recently I got around to another thing I've been meaning to do, which is to allow more than one screen capture per program. I was getting pretty tired of seeing the same pictures, and plenty of programs have lots of sample images up on their web sites. Part of the reason was laziness on my part, and part was poor software design. I'm not sure which of these I feel better about.


The software design aspect was something that has bitten me before, and I haven't learned.

In my haste to get the screen captures feature implemented, I made 'screencap' a field of the 'program' table in the database. This is easy: it only requires adding one field to the database and then remembering to extract the name of the screen capture image file when I retrieve the program's name, URL and so forth. Of course, the limitation here is that there is only one field for a screen capture file so it doesn't scale nicely, or at all.
So I went back in recently and as usual improving the design took no time at all. I made a new database table called 'image', which will be used to store the details of all images. There's a field in the table that links back to the 'program' table, so with one more MySQL call I can get all the screen captures that relate to a program. I should have done it this way to start with.
Of course, once I started with the database table for the image files, new improvements suggested themselves. The biggest gain is that I can now quickly pull up the exact size of an image and include this as part of the img tag in the HTML. This should help the pages load faster as the browser now knows exact image sizes in advance, instead of having to load the images to determine their size.

The other improvement was to pre-calculate reduced size versions of each image capture file. I use three sizes: full sized, for the popup screen captures, 320 pixel width for the pages of just screen caps, and 200 pixel width for the screen cap tooltip popup. I have to admit that previously I'd been loading the entire image file even when it was just displayed at 320 pixel width. With the reduced image files, the 320-width version can be 10 times smaller than the full size. Needless to say I used PerlMagick, the Perl API to ImageMagick, as I have hundreds of image files to process and am not fond of doing things by hand (I characterize this as Actual Work whereas programming is more along the lines of recreation). The image-creating program got a bit involved, as it has to check for database duplicates, come up with unique image file names and so forth. But the gist of the work is done in just a few lines:
$image->Scale(width => $newwidth,
height => $newheight);
$image->Composite(image => $magimage,
compose => 'Atop',
gravity => 'SouthEast');
The first bit does the scaling, obviously, and the second adds the little magnifying glass icon to the bottom right corner. I'd pre-calculated this to be 40% transparent so it doesn't overpower the screen cap image. Now that I've put the work into writing a program to create the reduced size image files, I can easily change their size or add a new size. Should have done it this way the first time.
The screen caps on this page are largely gratuitous. And they're all volume renderings because they just look good. All the programs that do volume renderings do a lightbox view as well, but for the purposes of general illustration the volume renderings work well. And I have plenty of images to use, I just added 170 so now have just over 300 screen caps. I started with the most active programs and now slowly I'm working my way through all the programs, visiting their websites and capturing images (I'm up to 'D'). Programs that I have personally used often have a capture of my own MRI.
