Jpgtn writes one output file for each JPEG image file specified on the command line. In order to be able to associate these output files with the input files that they are generated from, jpgtn names them based on the input filename. In order to avoid accidental overwriting of the input files, jpgtn allows you to specify a prefix to prepend to each input filename to construct the output filename. Jpgtn also allows you to specify a directory to write the output files to. If no directory and no prefix is specified, jpgtn writes the output files to the current directory using names constructed by prepending the default prefix "tn_" to the input filenames.
If no prefix is specified, but a directory is specified, jpgtn will write one file for each input file to the directory. The resultant files will have the same filenames as the original images they were generated from.
If no directory is specified, but a prefix is specified, then jpgtn writes its output files to the current directory and names its output files by prepending the supplied prefix to the filename of the original image.
If both a directory and a prefix are specified, them jpgtn writes its output files to the specified directory and prepends the supplied prefix to the original image's filename to construct the output file's name.
The -S option forces jpgtn to write its output to stdout. If this option is supplied, jpgtn ignores the -d and the -p options. This option is useful if you want to take advantage of output redirection or if you want to dynamically generate thumbnails for a CGI application.
The -s option gives you some control over the size of the thumbnails that are generated. If you do not supply this option, a default size of 128 pixels is assumed. The number of pixels in the longest dimension of a thumbnail generated by jpgtn will not exceed 'size' pixels. E.g. if you supply this option with a parameter of 100 while making a thumbnail of a 200x100 pixel image, the resulting image will be 100x50 pixels. If the original jpeg is 200x200 pixels, the thumbnail will be 100x100, and so on.
The -q option sets the JPEG quality level of the output JPEG file. This defaults to 70, and although values between 1 and 100 inclusive are allowed, I would suggest that 15 is probably as low as you can go without running into readability problems etc., and there isn't much point going above 90. Also, note that quality level 100 is not lossless, nor is the quality level a percentage. See the JPEG FAQ for further enlightenment.
To create thumbnails of all the '.jpg' files in the current directory and output them to the current directory with the default prefix "tn_" use:
$ jpgtn *.jpg
To do the same thing as above, but to put the thumbnails in './thumbs' use:
$ jpgtn -d "./thumbs/" -p "tn_" *.jpg
To create a thumbnail of the file image.jpg no larger than 75x75 pixels and
pipe it through the (hypothetical) program "jpegprog" use:
$ jpgtn -S -s 75 image.jpg | jpegprog
To create a thumbnail which has a width of 64 pixels and maintains the original's height/width ratio from a file called foo.jpg use:
$ jpgtn -W -s 64 foo.jpg
To create a thumbnail which has a height of 64 pixels and maintains the original's height/width ratio from a file called bar.jpg use:
$ jpgtn -H -s 64 bar.jpg
Thanks to the Independent JPEG Group for writing their useful and flexible JPEG software, without which this program could not use the JPEG/JFIF file format.
Thanks to Willie Daniel who created gtnpic which this program is derived from. Thanks to Russell Marks who created tnpic which was the foundation for gtnpic and therefore the foundation of jpgtn as well.
Thanks to Terry Mackintosh for suggesting that there should be a way to make jpgtn resize a specified dimension while allowing the other dimension to float.