Append to Multi-Page Image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
CosminU

Append to Multi-Page Image

Post by CosminU »

Greetings,

I need to programatically append to a multi-page TIFF or PDF a new image. The problem is that the individual images (that compose the multi-page one) have large resolutions and ImageMagick first loads the entire multi-page image into memory, which takes all the system's memory.

I need to be able to append to a multi-page image without having to load the entire image into memory. Is this possible with ImageMagick? Which C\C++ functions should I use?

Regards,
Cosmin
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Append to Multi-Page Image

Post by fmw42 »

I don't recommend using IM for such a task with PDF. As I understand it, IM converts vector formats such as PDF to raster and then back to vector for PDF. So there will be a loss in quality. see http://www.imagemagick.org/Usage/formats/#vector

Appending to tiff is possible, but I doubt without reading all the pages first. But I will defer to the IM experts.

IM tiff documentation is at http://www.imagemagick.org/Usage/formats/#tiff
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Append to Multi-Page Image

Post by anthony »

IM can not append to an existing image file format.
All it can do is read the format into memory, add the image and write it out again.
This generally works, but not always successfully. unfortunateally it will break down on very long files which can not all be loaded into memory all at the same time. Video Formats for example.

For true appending to an existing image file format you will need to look for a tool specific to the image file format that is involved.

Some formats can be just simply appended. The NetPBM file formats for example, allows you to do this, or the IM internal format MIFF. I do not however think TIFF can do this, so some special 'add image to existing file' must be used.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
CosminU

Re: Append to Multi-Page Image

Post by CosminU »

Thank you for your answers! Greatly appreciated.

Regards,
Cosmin
Post Reply