Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial 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

DIAGCOLLAGE


Collages three images in a diagonal orientation.

Download Script

last modified: April 25, 2015



USAGE: diagcollage [-s size] [-b bordercolor] [-t thickness] [-d direction] [-g1 gravity1] [-g2 gravity2] [-g3 gravity3] [-c1 crop1] [-c2 crop2] [-c3 crop3] infile1 infile2 infile3 outfile

USAGE: diagcollage [-h or -help]

-s .... size ......... square output size; even integer>0; default=400
-b .... bcolor ....... border color; default=white
-t .... thick ........ border thickness; even integer>>; default=10
-d .... direction .... direction of 5 deg rotation; p (positive) or
...................... n (negative); default=p
-g1 .... gravity1 .... crop gravity setting for image 1; default=center
-g2 .... gravity2 .... crop gravity setting for image 2; default=center
-g3 .... gravity3 .... crop gravity setting for image 3; default=center
-c1 .... crop1 ....... crop offsets for image 1; default="+0+0"
-c2 .... crop2 ....... crop offsets for image 2; default="+0+0"
-c3 .... crop3 ....... crop offsets for image 3; default="+0+0"

PURPOSE: Collages three images in a diagonal orientation.

DESCRIPTION: DIAGCOLLAGE collages three images in a diagonal orientation. The first image will span the top half (before rotation) and the other two images will be on the bottom left and bottom right quadrants, respectively.

ARGUMENTS:

-s size ... SIZE is the even square output size. Values are even integers>0. The default=400.

-b bcolor ... BCOLOR is the border color. Any valid IM opaque color is permitted. The default=white.

-t thick ... THICK is the border thickness. Values are even integer>0. The default=10.

-d direction ... DIRECTIONS of the 5 deg rotation. Values are: p (positive) or n (negative). The default=p (positive).

-g1 gravity1 ... GRAVITY1 is the crop gravity setting for image 1. Any IM gravity setting is allowed. The default=center.

-g2 gravity2 ... GRAVITY2 is the crop gravity setting for image 2. Any IM gravity setting is allowed. The default=center.

-g3 gravity3 ... GRAVITY3 is the crop gravity setting for image 3. Any IM gravity setting is allowed. The default=center.

-c1 crop1 ... CROP1 is the crop offsets for image 1. The format is +-X+-Y. The default="+0+0".

-c2 crop2 ... CROP2 is the crop offsets for image 1. The format is +-X+-Y. The default="+0+0".

-c3 crop3 ... CROP3 is the crop offsets for image 1. The format is +-X+-Y. The default="+0+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.


EXAMPLES


Image 1

Image 2

Image 3

Arguments:
-g1 south

Arguments:
-g1 south -g2 southeast -g3 northwest -d p -c1 "+0+0" -c2 "+100+100" -c3 "+100+200"

Arguments:
-g1 south -g2 southeast -g3 northwest -d n -c1 "+0+0" -c2 "+100+100" -c3 "+100+200"



What the script does is as follows:

  • Crops each image appropriately, then resizes, then crops again,
    then adds a border where needed
  • Appends them with the first on top and the other two side-by-side below
  • Rotates, crops and finally adds a final border

This is equivalent to the following IM commands for
the case of horizontal append:

  • osize=`convert xc: -format "%[fx:$size-2*$thick]" info:`
  • size=`convert xc: -format "%[fx:1.1*$size]" info:`
  • size2=`convert xc: -format "%[fx:$size/2]" info:`
  • thick2=`convert xc: -format "%[fx:$thick/2]" info:`
  • if [ "$direction" = "p" ]; then
    sign="+"
    elif [ "$direction" = "n" ]; then
    sign="-"
    fi
  • convert \
    \( $infile1 -gravity $gravity1 -crop $crop1 +repage -resize ${size}x \
    -crop ${size}x${size2}+0+0 +repage -background $bcolor -gravity south -splice 0x$thick \) \
    \( $infile2 -gravity $gravity2 -crop $crop2 +repage -resize ${size2}x${size2}^ -gravity center \
    -crop ${size2}x${size2}+0+0 +repage -gravity east -chop ${thick2}x0 -background white -splice ${thick2}x0 \) \
    \( $infile3 -gravity $gravity3 -crop $crop3 +repage -resize ${size2}x${size2}^ -gravity center \
    -crop ${size2}x${size2}+0+0 +repage -gravity west -chop ${thick2}x0 -background white -splice ${thick2}x0 \) \
    \( -clone 1 -clone 2 +append \) \
    -delete 1,2 -append \
    -background $bcolor -rotate ${sign}5 +repage \
    -gravity center -crop ${osize}x${osize}+0+0 +repage \
    -bordercolor $bcolor -border $thick "$outfile"