append images vertically using MagickWand C API.
Posted: 2017-04-21T03:32:22-07:00
I have multiple images and I need to append them and convert it to one image. For that I wrote below C program, it works fine except it appends images horizontally. How can I append images one after another?
For example using appends images horizontally and append vertically. I want to do it vertically.
For example using
Code: Select all
convert +append
Code: Select all
convert -append
Code: Select all
int main(int argc, const char * argv[]){
MagickWand * wandG1, * wandG2, * wandG3, * wandG4;
wandG = NewMagickWand();
MagickReadImage(wandG, "lala.jpg");
wandG1 = CloneMagickWand(wandG);
wandG2 = CloneMagickWand(wandG);
wandG3 = CloneMagickWand(wandG);
MagickRollImage(wandG1, 2, 0);
MagickWriteImage(wandG1,"tile2x0.jpg");
MagickRollImage(wandG2, 4, 0);
MagickWriteImage(wandG2,"tile4x0.jpg");
MagickRollImage(wandG3, 6, 0);
MagickWriteImage(wandG3,"tile6x0.jpg");
MagickSetLastIterator(wandG);
MagickAddImage(wandG, wandG1);
MagickAddImage(wandG, wandG2);
MagickAddImage(wandG, wandG3);
MagickSetFirstIterator(wandG);
wandG4 = MagickAppendImages(wandG,MagickFalse);
MagickWriteImage(wandG4,"tile.jpg");
if(wandG)wandG = DestroyMagickWand(wandG);
if(wandG)wandG1 = DestroyMagickWand(wandG1);
if(wandG)wandG2 = DestroyMagickWand(wandG2);
if(wandG)wandG3 = DestroyMagickWand(wandG3);
MagickWandTerminus();
return 0;
}