There are a thousand things that people want to make thumbnail images of. Very often people want to put a gallery of images online, and they're at a loss for a way to make thumbnails for that gallery. [url=http://www.latenightpc.com/forum/thread-40.html]As I've mentioned before[/url], I like to use [url=http://www.ImageMagick.org/]ImageMagick[/url]. ImageMagick is a very versatile command-line graphics program.
Anyhow, instead of [i]mogrify[/i], which would change the original file, I've got a simple line that uses [i]convert[/i] to produce a thumbnail. It uses the -thumbnail option for convert which strips out JPEG EXIF data and performs antialiasing. Other than that, it works like the -resize option. Stripping out EXIF data is fine since some of it might no longer be true in the thumbnail anyhow. Antialiasing is critical to get a decent looking image. In brief, antialiasing removes the 'jaggies' by smoothing out pixels as the size is reduced.
Okay, lets get down to businiess. I wanted a way to make a thumbnail of one photo or many in a folder. I want the thumbnail in the same folder as the original, so it needs a different name. Finally, I only need this to work on Windows XP (although my solution would work as is on Windows 2000 and with some little changes on Window 98 ).
Suppose you have a photo named [b]MyCar.jpg[/b]. To make a thumbnail of this one picture called [b]MyCar-sm.jpg[/b], ImageMagick takes the simple command line
[code:1]
convert.exe -thumbnail 160x160 "MyCar.jpg" "MyCar-sm.jpg"
[/code:1]
The 160x160 part means the thumbnail will be 160 pixels wide and 160 pixels tall.
It's easy to make a batch file that works on one or many files with the Windows [b]for[/b] command and the improved variable substitution rules in Windows 2000 and up. My batch file is called [b]mkthumb160x160.bat[/b] and all it has in it is this:
[code:1]
for %%f in (%1) do (
convert.exe -thumbnail 160x160 "%1" "%~n1-sm%~x1"
)
[/code:1]
I could use it to make thumbnails by running it at the command line, but I'd rather select the files in Explorer then right-click and pick "Make Thumbnails." Now that I have a batch file that takes a list of files, that's not hard at all.
To add a new command to the context menu, just open up Windows Explorer and choose "Folder Options" from the "Tools" menu. In the "Folder Options" dialog that appears, choose "File Types":
[img]http://www.latenightpc.com/bb2_files/folder_options1.png[/img]
Next, scroll down to the image type you want (jpg for me, but you might also want to do this for png, bmp or gif) and click the "Advanced" button.
[img]http://www.latenightpc.com/bb2_files/edit_file_type1.png[/img]
As you can see in the picture, I saved my batch file as c:\util\mkthumbs.bat, so in the "Application used to perform action" box, I filled in [code:1]C:\util\mkthumb160x160.bat "%1"[/code:1]
The text that you put in the "Action" box is what will show up when you right click on one or more of that type of file.
That's all there is to it. Go give it a shot!
Post new comment