--- /dev/null
+
+# get includes and libraries from source directory
+SRC=$(shell pwd )/../..
+CFLAGS=-I$(SRC) -L$(SRC)/MagickWand/.libs -L$(SRC)/MagickCore/.libs
+
+# get includes and libraries from installed ImageMagick-devel Package
+#CFLAGS=-I/usr/include/ImageMagick
+
+LDLIBS=-lMagickWand -lMagickCore
+
+files=$(wildcard *.c)
+tests=$(files:%.c=%)
+
+all: $(tests)
+
+script-token-test: script-token-test.c ../script-token.[ch]
+ $(CC) -o script-token-test script-token-test.c
+
+clean:
+ rm -f $(tests)
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *input,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Check prepend when using 'FirstIterator' on empty wand\n");
+ printf("Result shoud be: 3210\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+
+ MagickSetFirstIterator(wand); /* set first iterator to empty wand */
+
+ status = MagickReadImage(wand, "font_0.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_1.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_3.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *input,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Add 3 sets of images after setting 'first' on empty wand\n");
+ printf("Result shoud be: 678 345 012\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+ input = NewMagickWand();
+
+ MagickSetFirstIterator(wand);
+
+ status = MagickReadImage(input, "font_0.gif" )
+ && MagickReadImage(input, "font_1.gif" )
+ && MagickReadImage(input, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_3.gif" )
+ && MagickReadImage(input, "font_4.gif" )
+ && MagickReadImage(input, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_6.gif" )
+ && MagickReadImage(input, "font_7.gif" )
+ && MagickReadImage(input, "font_8.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ input=DestroyMagickWand(input); /* finished */
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *input,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Read 4 images, then set index 1 and read more individual images\n");
+ printf("Result shoud be: 01 654 23\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+ input = NewMagickWand();
+
+ status = MagickReadImage(input, "font_0.gif" )
+ && MagickReadImage(input, "font_1.gif" )
+ && MagickReadImage(input, "font_2.gif" )
+ && MagickReadImage(input, "font_3.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ input=DestroyMagickWand(input); /* finished */
+
+ MagickSetIteratorIndex(wand, 1);
+
+ status = MagickReadImage(wand, "font_4.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_6.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Check append when using 'LastIterator' on empty wand\n");
+ printf("Result shoud be: 0123\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+
+ MagickSetLastIterator(wand); /* to empty wand */
+
+ status = MagickReadImage(wand, "font_0.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_1.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_3.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *input,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Add 3 sets of images after setting 'last' on empty wand\n");
+ printf("Result shoud be: 012 345 678\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+ input = NewMagickWand();
+
+ MagickSetLastIterator(wand);
+
+ status = MagickReadImage(input, "font_0.gif" )
+ && MagickReadImage(input, "font_1.gif" )
+ && MagickReadImage(input, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_3.gif" )
+ && MagickReadImage(input, "font_4.gif" )
+ && MagickReadImage(input, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_6.gif" )
+ && MagickReadImage(input, "font_7.gif" )
+ && MagickReadImage(input, "font_8.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ input=DestroyMagickWand(input);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand, /* red image wand */
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Read 3 sets of 3 Images, each set with settings: none, first, last\n");
+ printf("Result shoud be: 543 012 678\n");
+
+ MagickWandGenesis();
+
+ /* read in the red image */
+ wand = NewMagickWand();
+
+ /* add test from empty wand */
+ status = MagickReadImage(wand, "font_0.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_1.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* add test to start */
+ MagickSetFirstIterator(wand);
+ status = MagickReadImage(wand, "font_3.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_4.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* add test to end */
+ MagickSetLastIterator(wand);
+ status = MagickReadImage(wand, "font_6.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_7.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_8.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand, /* red image wand */
+ *input, /* red image wand */
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Add 3 sets of image using settings: none, first, last\n");
+ printf("Result shoud be: 345 012 678\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+ input = NewMagickWand();
+
+ status = MagickReadImage(input, "font_0.gif" )
+ && MagickReadImage(input, "font_1.gif" )
+ && MagickReadImage(input, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_3.gif" )
+ && MagickReadImage(input, "font_4.gif" )
+ && MagickReadImage(input, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ MagickSetFirstIterator(wand);
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_6.gif" )
+ && MagickReadImage(input, "font_7.gif" )
+ && MagickReadImage(input, "font_8.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ MagickSetLastIterator(wand);
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ input=DestroyMagickWand(input);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Just read images one at a time, no settings\n");
+ printf("Result shoud be: 0123\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+
+ status = MagickReadImage(wand, "font_0.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_1.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ status = MagickReadImage(wand, "font_3.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *input,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ printf("Just read images in three groups, no settings used\n");
+ printf("Result shoud be: 012 345 678\n");
+
+ MagickWandGenesis();
+
+ wand = NewMagickWand();
+ input = NewMagickWand();
+
+ status = MagickReadImage(input, "font_0.gif" )
+ && MagickReadImage(input, "font_1.gif" )
+ && MagickReadImage(input, "font_2.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_3.gif" )
+ && MagickReadImage(input, "font_4.gif" )
+ && MagickReadImage(input, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ ClearMagickWand(input);
+
+ ClearMagickWand(input);
+ status = MagickReadImage(input, "font_6.gif" )
+ && MagickReadImage(input, "font_7.gif" )
+ && MagickReadImage(input, "font_8.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(input);
+
+ status = MagickAddImage(wand, input);
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+ input=DestroyMagickWand(input);
+
+ /* append all images together to create the output wand */
+ MagickResetIterator(wand); /* append all images */
+ output = MagickAppendImages(wand,MagickFalse);
+ wand = DestroyMagickWand(wand); /* finished - could swap here */
+
+ /* Final output */
+ status = MagickWriteImage(output,"show:");
+ if (status == MagickFalse)
+ ThrowWandException(output);
+
+ output = DestroyMagickWand(output);
+
+ MagickWandTerminus();
+}
+
--- /dev/null
+#include <stdio.h>
+#include <MagickWand/MagickWand.h>
+
+/* set this to true to test loops methods with a empty wand */
+#define TEST_EMPTY_WAND 0
+
+/* Simplify the exception handling
+ * technically we should abort the program if
+ * severity >= ErrorException
+ */
+void ThrowWandException(MagickWand *wand)
+{ char
+ *description;
+
+ ExceptionType
+ severity;
+
+ description=MagickGetException(wand,&severity);
+ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
+ description=(char *) MagickRelinquishMemory(description);
+}
+
+/* useful function especially after appending two wands together */
+#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
+
+int main(int argc, char *argv[])
+{
+ MagickWand
+ *wand,
+ *output;
+
+ MagickBooleanType
+ status;
+
+ MagickWandGenesis();
+
+ printf("Read in a list of 6 images...\n");
+
+ wand = NewMagickWand();
+#if !TEST_EMPTY_WAND
+ status = MagickReadImage(wand, "font_0.gif" )
+ && MagickReadImage(wand, "font_1.gif" )
+ && MagickReadImage(wand, "font_2.gif" )
+ && MagickReadImage(wand, "font_3.gif" )
+ && MagickReadImage(wand, "font_4.gif" )
+ && MagickReadImage(wand, "font_5.gif" );
+ if (status == MagickFalse)
+ ThrowWandException(wand);
+#endif
+
+ printf("I actually read in %u images\n",
+ (unsigned) MagickGetNumberImages(wand) );
+ printf("\n");
+
+ printf("After reading current image is #%d \"%s\"\n",
+ (unsigned) MagickGetIteratorIndex(wand),
+ MagickGetImageFilename(wand) );
+ printf("\n");
+
+ // Note that using MagickGetIteratorIndex() is slower than just
+ // keeping track of the current image index yourself! But not a great cost.
+
+ printf("Standard 'Reset while Next' loop through images\n");
+ // keeping track of it to start with!
+ MagickResetIterator(wand);
+ while (MagickNextImage(wand) != MagickFalse)
+ printf("image #%u \"%s\"\n",
+ (unsigned) MagickGetIteratorIndex(wand),
+ MagickGetImageFilename(wand) );
+ printf("\n");
+
+ printf("At this point, any image 'added' to wand will be appended!\n");
+ printf("This special condition can be set by using either\n");
+ printf("just MagickSetLastIterator(w)\n");
+ printf("or MagickSetIteratorIndex(w,-1)\n");
+ printf("\n");
+
+ printf("Now that we are at the end, lets loop backward using 'Previous'\n");
+ while (MagickPreviousImage(wand) != MagickFalse)
+ printf("image #%u \"%s\"\n",
+ (unsigned) MagickGetIteratorIndex(wand),
+ MagickGetImageFilename(wand) );
+ printf("\n");
+
+
+ printf("Note at this point, any image 'added' to wand will be prepended!\n");
+ printf("This special condition can be set by using either\n");
+ printf("just MagickSetFirstIterator(w)\n");
+ printf("Or MagickResetIterator(w); MagickPreviousImage(w);\n");
+ printf("The latter method being the cause of the current condition\n");
+ printf("\n");
+
+
+ printf("Directly loop though images backward using 'Last, while Previous'\n");
+ MagickSetLastIterator(wand);
+ while ( MagickPreviousImage(wand) != MagickFalse )
+ printf("image #%u \"%s\"\n",
+ (unsigned) MagickGetIteratorIndex(wand),
+ MagickGetImageFilename(wand) );
+ printf("\n");
+
+
+ printf("Loop through images using Indexes, in a weird flip-flop way!\n");
+ printf("Note that indexing using a negative number, indexes from end \n");
+ { ssize_t i;
+ ssize_t n = (ssize_t) MagickGetNumberImages(wand);
+
+ for ( i=0; i!=n; i= (i>=0) ? -(i+1):-i ) {
+ (void) MagickSetIteratorIndex(wand,i);
+ /* Note that a return of MagickFalse by the above is not actually an
+ * error (no exception will be generated). It just means that the
+ * index value used (positive or negative) is too large for the
+ * size of the current image list (EG: range error: -n <= i < n )
+ * When it does happen, no change is made to the current image
+ */
+ printf("index %2d -> #%u \"%s\"\n", (int) i,
+ (unsigned) MagickGetIteratorIndex(wand),
+ MagickGetImageFilename(wand) );
+ }
+ }
+ printf("\n");
+
+
+ wand=DestroyMagickWand(wand);
+
+ MagickWandTerminus();
+}
+
#define LocaleCompare(p,q) strcasecmp(p,q)
#define LocaleNCompare(p,q,l) strncasecmp(p,q,l)
#define WandSignature 0xabacadabUL
+#define fopen_utf8(p,q) fopen(p,q)
#define WandExport
/* Include the actual code for ScriptToken functions */