Read TIF multi-page

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
User6789
Posts: 2
Joined: 2014-11-17T04:26:36-07:00
Authentication code: 6789

Read TIF multi-page

Post by User6789 » 2014-11-17T05:53:11-07:00

Hi,

I would appreciate any help.

I am reading a TIFF file that has more than one page. But I only have access to the first page, and I need to read information from all them.

Anyone know how could I read the rest of the pages?

Thanks.

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Read TIF multi-page

Post by Bonzo » 2014-11-17T06:08:00-07:00

I know nothing about Magick++ but you could try input.tiff[1]
The pages will start at 0 so the first page will be [0] the second [1] etc.

User6789
Posts: 2
Joined: 2014-11-17T04:26:36-07:00
Authentication code: 6789

Re: Read TIF multi-page

Post by User6789 » 2014-11-17T06:45:13-07:00

Thanks Bonzo.

The solution is reading a list of

Code: Select all

Images
from a file.

Code: Select all

InitializeMagick(*argv);
list<Image> imageList; 
readImages( &imageList, "input.tif" );

int page = 0;
Image image = NULL;
for (list<Image>::iterator i=imageList.begin(); i != imageList.end(); i++){
     image = *i;
     image.write(to_string(page++) + ".png" );
}
This example extract each page in a PNG file named with their page number.

Post Reply