ddd Fred's ImageMagick Scripts: POSITION

Fred's ImageMagick Scripts



    Licensing:

    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.

POSITION


Positions (aligns) one image relative to another image.

Download Script

last modified: February 25, 2022



USAGE: position [-m method] [-d direction] [-o offset] [-l leftpt] [-r rightpt] [-b bcolor] [-f format] [-T trim] infile1 infile2 outfile

USAGE: position [-h or -help]

-m ... method ...... positioning method; choices are: offset or cpoints;
.................... default=offset
-d ... direction ... positioning direction; choices are: horizontal or
.................... vertical; default=horizontal
-o ... offset ...... offset +X+Y values for left/ope edge of second image
.................... relative to right/bottom edge of first image. Used when
.................... method=offset; positive or negative offsets are allowed;
.................... default=+0+0
-l ... leftpt ...... left (first) image control x,y point; default=0,0
-r ... rightpt ..... right (second) image control x,y point; default=0,0
-b ... bcolor ...... background color to fill empty spaces
-f ... format ...... output color format; choices are: RG, GB, BR or RGB;
.................... default=RGB
-T ... trim ........ trim output to remove any background fill areas

PURPOSE: To position one image relative to another image.

DESCRIPTION: POSITION aligns or offsets one image relative to a another image. The second image is positioned relative to the first image either horizontally or vertically. Positioning can be done using X and Y offsets or by specifying one controll point for each image.

ARGUMENTS:

-m method ... positioning METHOD. The choices are: offset (o) or cpoints (c). The default=offset.

-d direction ... positioning DIRECTION. The choices are: horizontal (h) or vertical (v). The default=horizontal.

-o offset ... OFFSET +X+Y values for left/top edge of second image relative to right/bottom edge of first image. This is used when method=offset. Position X and Y offsets may be either positive or negative. The default=+0+0

-l leftpt ... LEFT (first) image control x,y POINT. Values are integers>0. The default=0,0

-r rightpt ... RIGHT (second) image control x,y POINT. Values are integers>0. The default=0,0

-b bcolor ... BGCOLOR is the background color to fill empty spaces. Any Imagemagick color is allowed. The default=none (transparent)

-f format ... output color FORMAT; The choices are: RG, GB, BR or RGB. RGB is the normal color image. RG, for example, is first image in Red and second image in Green and any overlay will show in yellow (mix of Red and Green). The default=RGB.

-T trim ... TRIM output to remove any background fill areas. Choices are: yes (y) or no (n). The default=no. Background color must be unique in the image for the trim to work properly.

LIMITATIONS: TRIM option only works for Imagemagick 7.0.9-0 or higher.

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.


EXAMPLES


Example 1 - method=offset and format=RGB

Image 1

Image 2

Arguments:
-m offset -d horizontal -o +0+0 -b black -f RGB

Arguments:
-m offset -d horizontal -o +10+20 -b black -f RGB

Arguments:
-m offset -d horizontal -o +20-20 -b black -f RGB



Example 2 - method=cpoints

Image 1

Image 2

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f RGB

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f RG

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f GB

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f BR



Example 3 - method=cpoints and trim

Image 1

Image 2

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f RGB -T yes

Arguments:
-m cpoints -d horizontal -l 287,49 -r 76,89 -b black -f RGB -T no



What the script does is as follows:

  • uses page offsets and layers merge to combine the two images