Magick scripts are basically just the command line options as a script.
For example in the ImageMagick sources is a sub-directory "api_examples".
Here is a 'normal' shell script
Code: Select all
#!/bin/sh
#
# Assumes the "magick" command has been installed
#
magick -size 100x100 xc:red \
\( rose: -rotate -90 \) \
+append show:
this works much like you would probably expect.
Here is a Magick script
Code: Select all
#!/bin/env magick-script
# script.mgk
# Assumes the "magick-script" symlink to "magick" command has been installed
#
-size 100x100 xc:red
( rose: -rotate -90 ) # you can have comments in script too!
+append -write show:
It is basically exactly as per the command line options but without needing to backslash end of lines, parentheses, or other shell meta characters like !
but you can include comments in the middle of the script!
It can be run using
Or using the comamnd
Or if you used the 'HASH-BANG' scripting "#!/bin/env magick-script" (as showned above) which runs that file as a "magick-script" as it is found on your normal command path.
You should even be able to make DOS executable magick-scripts (as I made a '@' at the start of a line equivelent to a comment for DOS scripting, same for ':' or '#' for UNIX scripting)
Code: Select all
@echo This line is DOS executed but ignored by Magick
@magick -script %~dpnx0 %*
@echo This line is processed after the Magick script is finished
@GOTO :EOF
#
# The rest of the file is magick script
-read label:"This is a Magick Script!"
-write show: -exit
The scripts was supposed to also be able to read/process other image arguments, (using -args option). More imprtantally it was ment to allow you to implement 'montage-like' scripts. That is the script processes all (but the final write) like montage does, the script them can process the images in some way, and write the result to the file argument. I hoped to eventually replace montage itself with just a script and do away with the 'mess' of that commands code!
But I did not get to implementing that as I wanted to get -fx handling settings -- which is where I burned out.
So lets leave the magick-script at that for now.
The "function" type aspect, now that I am looking back at it, was also NOT completed.
The key here was the "-return" option.
Now suppose you create a 'function' magick script, that assumes you have an image in memory when it is called.
Say the file is called "half.mgk" and just resizes the image by 50%, but it could to just about any complex operation.
Code: Select all
# magick-script which expects a image already in memory
-resize 50%
-return
Now you can run it like...
Code: Select all
magick rose: -script half.mgk show:
You read in your images, run them through your 'function script' which 'returns' to let you continue processing.
The goals (and unimplented options) are documented in...
http://www.imagemagick.org/Usage/bugs/I ... ipting.txt
But the biggest goal -- pipelining commands into magick -- is working!
Even if 'co-processing' using a magick sub-process isn't quite working (I just tried using it for co-processing)
(Co-Processing:
http://www.ict.griffith.edu.au/anthony/ ... _hints.txt
Seems like this area is needing work. and I don't have the time to get into it!