convert multiple images to single pdf with library MagicWand

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
liuxiaomeng2270
Posts: 2
Joined: 2018-08-12T23:15:20-07:00
Authentication code: 1152

convert multiple images to single pdf with library MagicWand

Post by liuxiaomeng2270 » 2018-08-12T23:30:14-07:00

HI,

I'm trying to convert multiple images to one single pdf with MagicWand in C code.
I can save one image to one pdf file.
But I can't find a way to load all images in one container or some object to save the raster image data.

Is anybody has the code flow or API of MagicWand that I can call to load all image to one Object or container?

Any suggestions?


THX

snibgo
Posts: 10813
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert multiple images to single pdf with library MagicWand

Post by snibgo » 2018-08-13T10:42:49-07:00

Here's a wand program, but with no error-checking, that writes two images to a PDF:

Code: Select all

#include <MagickWand/MagickWand.h>

int main(void)
{
  MagickWandGenesis();

  MagickWand *mw = NewMagickWand();
  MagickReadImage(mw,"rose:");

  MagickWand *aw = NewMagickWand();
  MagickReadImage(aw,"toes.png");

  MagickAddImage(mw,aw);

  MagickWriteImages(mw,"out.pdf",MagickTrue);

  if(mw) mw = DestroyMagickWand(mw);
  if(aw) aw = DestroyMagickWand(aw);

  MagickWandTerminus();

  return 0;
}
snibgo's IM pages: im.snibgo.com

Post Reply