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. |
Pads an image with a color to a specified aspect ratio and orientation. |
last modified: December 15, 2018
USAGE: aspectpad [-a aspect] [-m mode] [-p pcolor] [-t toler] infile outfile
-a .... aspect ...... aspect ratio value desired; float>=1; default=2 PURPOSE: To pad an image with a color to a specified aspect ratio and orientation. DESCRIPTION: ASPECTPAD pads an image with a color to a specified aspect ratio and orientation. The user can choose to force the pad to either landscape or portrait orientation or preserve the orientation in automatic mode. All padding will result in the image being centered. ARGUMENTS: -a aspect ... ASPECT is the desired aspect ratio. Values are floats>=1. The default=2 -m mode ... MODE is the padding mode. Choices are: l, p, al or ap. When mode=l, the padding will force the result to be landscape at the desired aspect value. When mode=p, the padding will force the result to be portrait. When mode=al, the padding will preserve the aspect of the original image, but will pad a square image into landscape format. When mode=ap, the padding will preserve the aspect of the original image, but will pad a square image into portrait format. The default=al. -p pcolor ... PCOLOR is the desired padding color. Any valid IM color specification may be used. The default=black -t toler ... TOLER is the aspect tolerance. If the absolute difference between desired aspect and image aspect is less than or equal to toler, then no padding will be applied. Values are floats>=0. The default=0 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. |
Example 1 |
||
Original |
Arguments: |
Arguments: |
size 120x80 (3:2) |
size 160x80 (2:1) |
size 120x90 (4:3) |
Example 2 |
|||
Original |
Arguments: |
Arguments: |
Arguments: |
size 80x101 (4:5) |
size 80x120 (2:3) |
size 101x101 (1:1) |
size 152x101 (3:2) |
What the script does is as follows:
This is equivalent to the following IM commands for the case of automatic mode
|