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.

SCRIPTBATCH


Runs another script over a folder of images.

Download Script

last modified: October 27, 2018



USAGE: scriptbatch -c command [-i inputfolder] [-o outputfolder] [-f format] [-s suffix] [-p path2imagemagick]
USAGE: scriptbatch [-h or -help]

-c ... command ............ path to the script file with all its argument, except the
........................... input and output images; required; the whole command must
........................... be enclosed in single or double quotes
-i ... inputfolder ........ path to the input image folder including the folder name;
........................... default is the folder from which scriptbatch is called
-o ... outputfolder ....... path to the output image folder including the folder name;
........................... default is the same as the input folder; if the folder
........................... does not already exist, it will be created
-f ... format ............. format for filtering input images; space and/or comma
........................... separate list; default is that all files in the
........................... inputfolder will be processed; typical formats are
........................... jpg, png, tiff (case insensitive).
-s ... suffix ............. suffix is the extension to add to the output images
........................... without the period; default is the same suffix as the
........................... input; typical suffixes are jpg, png, tiff
-p ... path2imagemagick ... path to imagemagick convert/magick; default assumes it is
........................... in your PATH environment variable.

PURPOSE: To run another script over a folder of images.

DESCRIPTION: SCRIPTBATCH runs another script over a folder of images, but only those scripts that take one input and create one output and do not use arguments that need quoting.

ARGUMENTS:

-c command ... COMMAND is the path to the script script file with all its arguments as specified by the script in question. Do not include the input and output images. If an argument is a color definition, then it can only be a color name or a hex color without quotes. Other color specifications do not work. Also the script cannot handle any other arguments that require quoting. If the path to the script in in your PATH environment variable, then the path to the script may be left off. Use the script[.sh] as it is on your system. COMMAND is a required argument. Enclose it all in single or double quotes.

-i inputfolder ... INPUTFOLDER is the path to the the folder of input images and must include the folder name. The default is folder from which scriptbatch is called.

-o outputfolder ... OUTPUTFOLDER is the path to the output image folder including the folder name. The default is the same folder as the input folder. If the folder does not already exist, it will be created.

-f format ... FORMAT for filtering input images. Space and/or comma separate list. The default is to process all files in the inputfolder. Typical formats are: jpg, png, tiff (case insensitive). Example: "jpg,png" or "jpg png" or "jpg, png" will only process jpg and png format images.

-s suffix ... SUFFIX is the extension to add to the output images without the period. The default is the same suffix as the input. Typical suffixes are jpg, png, tiff.

-p path2imagemagick ... PATH2IMAGEMAGICK is the path to imagemagick convert/magick, excluding convert or magick. The default assumes it is in your PATH environment variable. Typical locations are: /usr/local/bin, /usr/bin, /opt/local/bin, etc.

NOTE: The scriptbatch script can use commands for scripts that take one input and one output only, respectively and do not use arguments that need quoting such as a list of control points or color specifications with parentheses, such as rgb(...). The exception is that colors may be specified as color names or hex values without quoting. The hex value must include the leading # symbol. Some scripts can use control points specified via a text file. Those scripts will work when using the textfile.

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


Runs Script, 2colorthresh (no arguments), providing full paths

/Users/fred/applications/ImageMagick-Scripts/bin/scriptbatch \
-c "/Users/fred/applications/ImageMagick-Scripts/bin/2colorthresh" \
-f png -s tiff -i /Users/fred/desktop/test1 -o /Users/fred/desktop/test2

Runs Script, 2colorthresh (no arguments), with scriptbatch, script and
images directories in working directory

scriptbatch -c "2colorthresh" -f png -s tiff -i test1 -o test2

Runs Script, textcleaner with its arguments, with scriptbatch, script and
images directories in working directory

scriptbatch -c "textcleaner -g -e stretch -f 25 -o 20" -f tif -s jpg -i test1 -o test2

Runs Script, bordergrid with its arguments, with scriptbatch, script and
images directories in working directory providing relative paths

scriptbatch -c "bordergrid -s 10 -t 2 -o 4 -d 1 -a 45 -b 0 -c #FFFFFF" -f png -s tiff \
-i ../desktop/test1 -o ../desktop/test2

Runs Script, curves with its arguments including pointfile.txt containing control points,
with scriptbatch, script and images directories in working directory

scriptbatch -c 'curves -c curve -f pointfile.txt' -f png -s tiff -i test1 -o test2