Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Resizes an image to a specific size allowing either cropping or padding to deal with the aspect ratio change |
last modified: December 15, 2018
USAGE: aspect widthxheight [-m mode] [-c color] [-g gravity] [-f filter] infile outfile
widthxheight ......... desired size (width x height); value in pixels PURPOSE: To resize an image to a specific size allowing either cropping or padding to deal with the aspect ratio change. DESCRIPTION: ASPECT resizes an image to a specific size allowing cropping or padding with a constant background color or transparent background. In either case, the aspect ratio of the image will be compared to the aspect ratio of the desired size and cropped or padded to fill one or the other dimension accordingly. ARGUMENTS: widthxheight ... WIDTHxHEIGHT specifies the desired output size. WIDTH and HEIGHT values must be specified as integer pixels. -m mode ... MODE specifies to either pad or crop the image to square it off. The default is crop. -c color ... COLOR specifies the background color to use when mode=pad. Any valid IM color specification may be used. To make the background transparent, set the color either to none or trans. The default is black. -g gravity ... GRAVITY is the region of the image to use when mode=crop. Values may be North, East, South, West or Center. The default is Center. -s sat ... SAT specifies a gain in saturation. Values for sat must be non-negative integers. A value of 100 indicates no saturation change. Larger/smaller values indicate more/less saturation. -f filter ... FILTER is any valid IM resize filter. The default is Lanczos. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Wider Than Tall Image | |||
Original Image |
|||
Arguments: |
Arguments: |
||
Arguments: |
Arguments: |
||
Square Image | |||
Original Image |
|||
Arguments: |
Arguments: |
||
Arguments: |
Arguments: |
||
Taller Than Wide Image | |||
Original Image |
|||
Arguments: |
Arguments: |
||
Arguments: |
Arguments: |
||
What the script does is as follows:
This is equivalent to the following IM commands for the
|