At the moment the features I know is working.
Where file.mgk contains all the command line options that you would normally put on the command line.
but without all the shell escapes, for shell meta characters and end of lines, and with '#' comments
or full line comments if the line begins with any of '#:@' That later allowing for self launching DOS scripts.
The Primary syntax source is the header of the script tokenizer "MagickWand/script-token.c"
Quote and whitespace escaping is based on what UNIX Bash does.
At the moment the script exits when finished. What it is suposed to happen is that the script continue processing either the calling script of command line arguments (if any). The final 'write' output file argument is optional after a -script option).
The script does not need to be a file but can be standard input.
You can now type options interactively.... ([what I type,
magick outputs)
2016-10-27_19.48.12.png
-identify
2016-10-27_19.48.12.png PNG 1280x720 1280x720+0+0 8-bit sRGB 1.241MB 0.060u 0:06.459
-exit
Or you can 'pipe' commands from your script into the command. for example like this "mogrify" like script...
Code: Select all
mkdir thumbnails
for image in *.png
do
echo >&2 "Processing image $image..."
echo "\"$image\" -resize 100x100 -write \"thumbnails/$image\" -delete 0--1"
done | magick -script -
This is working though I am seeing 'property' errors for some reason!
-------------------------------
This reading from a file stream should allow you to 'co-process' with
magick.
That is you run a "
magick" command in the background from your shell, C, PHP, Python script, and send it commands to process, while reading back information you request (using -print or -identify options) from the background process.
For example you can have "
magick" holding images in memory while the "master" program can ask for information about the images, and request them processed in various ways.
This is actually how most Database and Internet Services actually works! When you make a request from a web server or database, the server processes the request then returns a response, and that gives us a nice way to test
magick co-processing capabilities...
For example using "netcat" or "nc" to remotely control a "
magick" command on a remote system
Assuming the machine firewall has a open port on 8080 and no other program has a service using that port...
(
WARNING this is highly insecure and only an example)
On a Image Server in a image directory...
Code: Select all
nc --listen --sh-exec 'magick -script -' 8080
Now on another machine
-print "image count: %n\n"
image count: 0
-read "*.png[100x100]"
-print "image count: %n\n" # let us know when read is finished, and report how many images
image count: 101
-delete 0--4 # delete all but last three
-print "image count: %n\n"
image count: 3
-format "filename: %f size: %wx%h\n" -identify
filename: 2016-12-16_19.29.43.png size: 100x56
filename: endrod_fence.png size: 100x56
filename: tree_house_stair.png size: 100x56
+append
-print "image size %wx%h\n"
image size 300x56
-exit
That is a bare bones co-processing example, where you are controlling a remote "
magick" program running on a different machine! The comment that is sent to the remote "
magick" command is ignored. That print basically provides a way to discover when the previous 'read' (which could be a long time) or other sequence of image processing commands has finished. The setup however is not very 'error friendly' as it stands, if something goes wrong with this setup you do not get any notification of the error. But that can also be fixed in the way the "
magick" command is launched.