int convert_adjoin (MagickWand *input, MagickWand **output, convert_t *opts) { unsigned long pages = MagickGetNumberImages(input); uint32_t start = opts->page_start; uint32_t end = opts->page_end; if (pages < 2 || opts->format == INFO) return MagickPass; if (end && end < pages) { if (convert_remove_range(input, end, pages) != MagickPass) return MagickFail; pages = end; } if (start && pages) { start = MIN(start-1, pages); if (convert_remove_range(input, 0, start) != MagickPass) return MagickFail; pages -= start; } if (!pages) return MagickFail; if (!opts->split) { MagickResetIterator(input); input = MagickAppendImages(input, 1); } *output = input; if (*output == NULL) return MagickFail; if (opts->scale_height && !(opts->scale_options & MULTIPAGE)) opts->scale_height *= pages; return MagickPass; }
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(); }