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.

SPLITIMAGE


Generates a side-by-side append of two partial images with an option to animate the amount of each image used in the append.

Download Script

last modified: November 11, 2023



USAGE: splitimage [-m mode] [-b begin] [-f final] [-i increment] [-d delay] [ -r resize] [-v] infile1 infile2 [outfile]
USAGE: splitimage [-h or -help]

-m ... mode ....... split mode; LR, LL, RR, TB, TT or BB; default=LR
-b ... begin ...... (beginning) offset split position;
................... 0 to width-2 or height-2 depending upon mode;
................... default is the center, if outfile is a single frame;
................... default=0, if animation with or without outfile
-f ... final ...... (final) offset split position for animation;
................... 0 to width-1 or height-1 depending upon mode;
................... default=width-1 or height-1, depending upon mode
-i ... increment incremental shift of one image relative to second
................... per animation frame; 0 to width/4 or height/4;
................... default=10 pixels if no outfile provided;
................... default=0 with outfile indicates single frame output
-d ... delay ...... time delay per animation frame (ms); delay >= 0; default=3
-r ... resize ..... image resize percentage; resize > 0;
................... default=100 (unchanged)
-v ................ indicates to view (display) the outfile automatically
outfile ........... if no oufile is provided, an animation will be generated
................... and viewed (displayed) automatically without specifying
................... the -v option

PURPOSE: To generate a side-by-side append of two partial images with an option to animate the amount of each image used in the append.

DESCRIPTION: SPLITIMAGE generates a side-by-side append of two partial images, nominally half of each with the left half of the first image and right half of the second image. However, one can specify to use two left halves or two right halves or the top and bottom or two top halves or two bottom halves. Optionally the split between the two images can be animated for visual comparison of the difference/change between the the two images and the result saved and/or automatically displayed.

ARGUMENTS:

-m mode ... MODE is the split orientation of the two images. The choices are: LR (left/right), LL (left/left), RR (right/right), TB (top/bottom), TT (top/top), or BB (bottom/bottom)

-b begin ... BEGIN is the position for the split for a single frame output or the beginning position for an animation. The values may be between 0 and width-2 or height-2. The default is the center at width/2 or height/2 depending upon mode.

-f final ... FINAL is the final position for the split for an animation before it reverses and goes back to the beginning position to form a loop. The values may be between 0 and width-1 or height-1, but must be greater than Begin. The default is the width-1 or height-1 depending upon mode. Final is ignored if there is no animation.

-i increment ... INCREMENT is the pixel offset amount for the split location for each new frame of the animation. Increment values should be integers between 0 to width/4 or height/4, depending upon the mode. The default=0 indicates no animation and that a single frame output will be generated. If no outfile is specified, then an animation will automatically be generated and displayed. The default value in this case is 10 pixels.

-d delay ... DELAY is the time delay in msec between frames in the animation. Values are integers greater than or equal to zero. The default=3. Note that the animation will be created to loop forever. Delay is ignored if a single frame output is to be generated by specifying increment=0. The delay=3 will make a fast animation if displayed under X11. However, if the animation is saved to file and displayed in a browser, the browser will likely impose a larger delay per frame and the animation will appear slower.

-r resize ... RESIZE allows the output to made larger or smaller than the input image size. The values are integers greater than 0 representing the resize percentage. The default=100 which leaves the output the same size as the input image.

-v ... Specifies that along with the output animation, the outfile is to be viewed (displayed) automatically before the script is ended. If no output animation file is provided, the animation will be created and viewed automatically even if the -v option is not specified. This parameter is ignored if the output is a single frame image (increment=0).

infile1 and infile2 ... Both input images must be the same size.

outfile ... OUTFILE, if provided for an animation, must be in a format such as gif that supports multiframe animations.

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


Split Image - Grayscale vs Pseudocolor

Original Grayscale Image

Pseudocolored Image

 
 

Arguments:
-m LR

Arguments:
-m LL

Arguments:
-m RR

Arguments:
-m TB

Arguments:
-m TT

Arguments:
-m BB



Split Animation - Grayscale vs Pseudocolor - Full Range

Original Grayscale Image

Pseudocolored Image

 
 

Arguments:
-m LR -i 10

Arguments:
-m LL -i 10

Arguments:
-m RR -i 10

Arguments:
-m TB -i 10

Arguments:
-m TT -i 10

Arguments:
-m BB -i 10



Split Animation - Grayscale vs Pseudocolor - Partial Range

Original Grayscale Image

Pseudocolored Image

Arguments:
-m LR -i 3 -b 44 -f 88



Split Animation - Grayscale vs Laplacian Edge - Full Range

Original Grayscale Image

Laplacian Edge Image

Arguments:
-m LR -i 10



Split Animation - Color vs Sharpened - Full Range

Original Color Image

Sharpened Color Image

Arguments:
-m LR -i 10



What the script does is as follows:

  • Uses mode, begin, final, increment and delay parameters to
    append and optionally animate subsections of two images

The basic command line is:

  • convert $infile1[${wd1}x${ht1}+${ox1}+${oy1}] \
    $infile2[${wd2}x${ht2}+${ox2}+${oy2}] \
    $append +repage $outfile