NAME
sizimg - resize an image with anti-aliasing
SYNOPSIS
sizimg infile -o outfile -% percent -p [h[wp]][v[wp]] -k <s | g> -r deg -c codec -q quality -b bits -m -M metafile
sizimg infile -o outfile -w width -h height -p [h[wp]][v[wp]] -k <s | g> -r deg -c codec -q quality -b bits -m -M metafile
DESCRIPTION
Images can be resized with the use of the command-line tool sizimg. Tests have shown that the quality resulting from sizimg surpasses that of any other commercially available software.
sizimg is a UNIX-style command-line tool to be used on the Macintosh using the Terminal application, or in the Command Prompt window on Windows. As a command-line tool, it has no user interface, but it can be very powerful when incorporated into scripts. In particular, it can be used in shell scripts to batch process images.
The arguments and flags are described subsequently. Windows users may use a slash ("/") as well as a dash ("-") to indicate a flag. Note that the order of the flags does not matter, with the exception that flags with arguments must have their arguments immediately following.
infile
An argument without a preceding flag is considered to be the input file path. This is a required argument.-o outfile
The -o flag is immediately followed by a path name to the output file. It is a required argument.-% percent
The size of the output image may be specified either in percent or width and height. The percentage may have a decimal point in it, e.g. -% 70.71 will shrink the image by 70.71% (i.e. half the number of pixels). The size of the output image must be specified, either with a percent or explicitly with width and height.-w width
The desired width of the output image is specified in pixels. It is an error to also specify the percentage.If the width is specified, but the height is not, the height is computed so that the output image has the same aspect ratio as the input image. This can be especially useful for web pages, where it is not desirable to have images exceed a certain width, but it is OK to have an arbitrary height that might require scrolling. It is also useful for processing horizontal-circumference cylindrical or spherical panoramas (along with the -p h flag) to have a standard circumference or angular pixel density, but an arbitrary vertical field of view.-h height
The desired height of the output image is specified in pixels. It is an error to also specify the percentage.
If the height is specified, but the width is not, the width is computed so that the output image has the same aspect ratio as the input image. This can be especially useful for vertical-circumference cylindrical or spherical panoramas (along with the -p v flag) to have a standard circumference or angular pixel density, but an arbitrary horizontal field of view.
-p [h[wp]][v[wp]]
The -p flag specifies panorama mode, which implements wrapping around the image. This is an appropriate flag for use with 360° cylindrical or spherical panoramas. Two types of wrapping are implemented: wrap or pinch. Wrapping connects the last pixel in a [horizontal or vertical] scanline with the first one in the same scanline, and is appropriate for wrapping at the central meridian of a cylindrical or spherical panorama. Pinching connects the first (last) pixel in a [vertical or horizontal] scanline with the first (last) pixel halfway around, and is appropriate for the poles of an equirectangular spherical image.
To wrap horizontally, you would specify -p hw, whereas -p vw would wrap vertically; the former would be appropriate for a cylindrical panorama in standard position, and the latter for a cylindrical panorama in rotated position. To pinch vertically, you would specify -p vp, whereas -p hp would pinch horizontally. For convenience, you could merge the horizontal and vertical specifications together, e.g. to resize an equirectangular spherical image in standard position, you could specify -p hwvp, or -p vphw, or you could include two separate flags: -p hw -p vp. The -p flag is optional, and its omission results in treating the image as though it does not wrap around.
No other software offers a wrapping option when resizing images, and their use can result in discontinuities at the seam of panoramas. This flag qualifies sizimg uniquely as the tool with which to resize panoramas.
-k [s | g]
The kernel for anti-aliasing can be chosen to be either a Lanczos-windowed sinc (-k s) function or a Gaussian (-k g). The sinc function is the default, and should be the best for most applications, because it is sharper than the Gaussian. However, a slight amount of ringing may be introduced by the sinc function kernel, and although this tends to visually enhance the edges in the image, the ringing may be undesirable in some applications. The Gaussian is a totally positive kernel, and hence does not introduce any ringing under any circumstances. The -k flag is optional, and defaults to the sinc kernel.-r degrees
Prior to writing (and after resizing), the image may be rotated clockwise by any positive or negative multiple of 90 degrees. If the specified rotation angle is not a multiple of 90 degrees, it will be truncated downward to a multiple. Note that the dimensions are to be specified in unrotated coordinates. For example, if img2000x1000.jpg is 2000 pixel wide by 1000 pixel high, then
sizimg img2000x1000.jpg -w 1000 -h 500 -r -90 -o halfimg.jpgwill first resize it to 1000x500, then rotate it counter-clockwise by 90 degrees, resulting in an image that is 500 pixels wide by 1000 pixels tall.
-c codec
QuickTime is used to read the input image and to write the output image. It can read and write a wide variety of formats.
The following are the input formats available as of QuickTime 7.0.4:
Import Formats Codec
CodeFile
ExtensionCodec
DescriptionNote .SGI SGI Silicon Graphics Use quotes: '.SGI' to assure that the leading period is included 8BPS PSD PhotoShop BMP
BMPf
BMPp
DIBBMP
DIBWindows BMP FPX
FPixFPX
FPIXFlashPix GIF
GIFfGIF GIF JP2 JP2 JPEG 2000 JPEG
JPG
JPEJPEG
JPG
JPEJPEG PICT
PIC
PCTPICT
PIC
PCTApple PICT PNGf
PNGPNG PNG PNTG
MACPNTG MacPaint Only bilevel black and white & one size QTIF
QTI
QTFQTIF
QTI
QTFQuickTime Image File TIFF TIF
TIFFTIFF TPIC TGA Targa JP2 JP2 JPEG 2000 Use quotes 'jp2 ' to assure that the trailing space is included The following are the output formats available as of QuickTime 7.0.4:
Output Formats Codec
CodeFile
ExtensionCodec
DescriptionNote .SGI SGI Silicon Graphics Use quotes: '.SGI' to assure that the leading period is included 8BPS PSD PhotoShop BMPf
BMPBMP Windows BMP JPEG JPG JPEG MIFF IFF Maya IFF PICT PCT Apple PICT PNGf PNG PNG PNTG PNTG MacPaint Only bilevel black and white & one size TIFF TIF TIFF TPIC TGA Targa JP2 JP2 JPEG 2000 Use quotes "jp2 " to assure that the trailing space is included Note that both the codec code and file extensions are case insensitive.
The -c flag takes one of the above codec codes as an argument.
The file extension found on the input file tells QuickTime how to decode it.
I recommend the JPEG (lossy) and PNG (lossless) codecs in general. The following codecs are lossless: SGI, PhotoShop, BMP, MIFF, PICT, PNGf, TIFF, TPIC.
The MacPaint codec is useless.
The -c flag is not required, and defaults to JPEG.
-q quality
This specifies the quality of the output image. It only affects the JPEG and JP2 codecs. I find the range from 40-75 to be most useful. This flag is optional, and defaults to 75.-b bits
You can specify the number of bits per pixel to be used for the output image. The useful values are listed in the table below. We don't acommodate grayscale output at the moment.
Bits Per Pixel Components Bits Per Component Codecs 16 Red, Green, Blue 5, 6, 5 Targa 24 Red, Green, Blue 8, 8, 8 PNG, TIFF, Photoshop, JPEG-2000, Targa, BMP, JPEG
32 Alpha, Red, Green, Blue 8, 8, 8, 8 PNG, TIFF, Photoshop, JPEG-2000, Targa 48 Red, Green, Blue 16, 16, 16 PNG, TIFF, Photoshop 64 Alpha, Red, Green, Blue 16, 16, 16, 16 PNG, TIFF, Photoshop -m
Transfer metadata (e.g. EXIF) from the input to the output image, with appropriate modifications for image dimensions and focal plane resolutions.-M metafile
Print the input image metadata to the specified metafile, or to the standard output if a dash ("-") is used in place of the file name.-?
This flag prints a help message. The help message is also printed when no arguments are supplied, or when there is an argument error. Note that the question mark should be escaped with a backslash in the shell, i.e.
-\? .-v
This flag turns verbose mode on, to indicate progress. the format is subject to change, but currently this takes the form:Reading "srcImg.jpg"
Resizing NxM to PxQ
Writing "dstImg.jpg"
EXAMPLES
sizimg mom.jpg -o bigmom.jpg -% 200
sizimg courtyard.jpg -o courtyard.1024x512.jpg -w 1024 -h 512 -p hw
sizimg store.rot.jpg -o store.rot.768x2496 -w 768 -h 2496 -p vw
sizimg sph.jpg -o sph.1600x800.jpg -w 1600 -h 800 -p hwvp
sizimg -h 64 -w 48 /Users/turk/Pictures/me.jpg -o website/images/meThumb.jpg
sizimg -w 100 -v -o zoneplate.100.tif -c tiff zoneplate.tif
sizimg -w 640 pic.jpg -o pic.640.jpg -q 50 -m
sizimg -% 25 -b 48 pic.jpg -c png pic48.png
COST
This program is shareware. If you find it useful, please send $5 or more to turk at computer dot org via PayPal to encourage other useful tools and applications.
DOWNLOAD
Macintosh OS X
Download
Windows
Download
Product Rating Downloads sizimg add a comment Data provided by VersionTracker
Product Rating Downloads sizimg add a comment Data provided by VersionTracker
INSTALLATION (Macintosh)
If you have root privileges, you can install sizimg into /usr/local/bin, to allow access to everyone on you system. Otherwise make a bin directory in your home directory and put it there. Here is a typical sequence for the bash shell:
- mkdir ~/bin
- cp ~/Desktop/sizimg/sizimg ~/bin
- echo 'setenv PATH "$PATH":"$HOME"/bin' >> ~/.bashrc
and for the tcsh shell:
- mkdir ~/bin
- cp ~/Desktop/sizimg/sizimg ~/bin
- echo 'set path =($path ~/bin)' >> ~/.tcshrc
- source ~/.tcshrc
- rehash
Of course, if you already have a ~/bin directory and have your PATH set to include it, you do not need anything other than the cp commands.
INSTALLATION (Windows)
I know just enough Windows to be dangerous. If you need more help than this to install sizimg, you'll have to seek help elsewhere.
- Choose a directory to store commands. I store mine in
C:\Program Files\bin- Copy sizimg.exe to this location.
- Right-click on the "computer" icon on your desktop, or select
Start > Control Panels > System.- Click the "Advanced" tab
- Click the "Environment Variables" button.
- Look through the User variables for a variable called "path". Edit this to make sure that the path to sizimg is listed. If there is no such entry, create one.
- Log out and in again. Maybe you have to reboot instead.
BUGS
No more than 14 bits of precision are available per component; the least significant 2 bits of 16 bit components (in the 48 and 64 bit pixel formats) are replicated from the most significant bits, thus ensuring the full dynamic range. Thus there are only 4,398,046,511,104 rather than 281,474,976,710,656 unique colors available in the 48 bit formats.
last updated 2005-11-23