Multi-page tiff to single page tiff - crashing Windows

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dr_d_nice
Posts: 3
Joined: 2015-12-10T09:45:49-07:00
Authentication code: 1151

Multi-page tiff to single page tiff - crashing Windows

Post by dr_d_nice »

I am attempting to convert a multi-page tiff to a single page tiff.
The multi-page tiff is quite large, ~700 pages.

When I run the following command:

Code: Select all

convert multipage.tif singlepage%d.tif
...the RAM usage maxes out (16gb), rendering the computer useless during the operation. After waiting 5 minutes, I ended the command (ctrl+c). I have yet to successfully convert these large multipage tiff files.

Any ideas?

Running ImageMagick-6.9.2-Q16 on Windows 7 (same issue with PowerShell & CMD prompt)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multi-page tiff to single page tiff - crashing Windows

Post by fmw42 »

Sounds like you are running out of RAM. The whole 700 page TIFF file must be loaded into RAM. Do you have enough RAM? If not, then you need to use disk for RAM. See

http://www.imagemagick.org/Usage/files/#massive
http://www.imagemagick.org/script/resou ... nvironment
viewtopic.php?f=4&t=26801

Sorry, I am not an expert on such configuration
dr_d_nice
Posts: 3
Joined: 2015-12-10T09:45:49-07:00
Authentication code: 1151

Re: Multi-page tiff to single page tiff - crashing Windows

Post by dr_d_nice »

The multi-page tiff file is 24MB, my computer has 16GB of RAM.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multi-page tiff to single page tiff - crashing Windows

Post by fmw42 »

It should then work, but may take quite some time to read and write 700 pages of the file. If you have any doubts, then post your TIFF file to some place such as dropbox.com and put the URL here so we can test and see if the file works or is corrupted.

If you want to test the file, then just read the image and save just the first page, but it still may take some time to read all the pages:

Code: Select all

convert multipage.tif[0] singlepage0.tif
Alternately, do

Code: Select all

identify multipage.tif
to see how long it takes to read the file and list the short information.
dr_d_nice
Posts: 3
Joined: 2015-12-10T09:45:49-07:00
Authentication code: 1151

Re: Multi-page tiff to single page tiff - crashing Windows

Post by dr_d_nice »

Thank you for your help. I apologize but I am unable to share the document, it's IP belonging to my employer. I am hoping to use ImageMagick to "revolutionize" how we handle these documents.

I was able to successfully and quickly produce single page .tif & .pdf using convert. I also selected different pages, no issues...however I get this odd message:

Code: Select all

PS C:\> convert SPEC1.tif[0] SPEC_page1.tif
convert.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/887.
PS C:\> convert SPEC1.tif[0] SPEC_page1.pdf
convert.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/887.
PS C:\>
I also ran the identify command, it completed quickly (maybe 1 second) and successfully. Reporting all 683 pages, returning a similar error as before:

Code: Select all

SPEC1.tif[681] TIFF 1656x2339 1656x2339+0+0 1-bit Bilevel Gray 23.98MB 0.218u 0:02.111
SPEC1.tif[682] TIFF 1656x2339 1656x2339+0+0 1-bit Bilevel Gray 23.98MB 0.218u 0:02.114
SPEC1.tif[683] TIFF 1656x2339 1656x2339+0+0 1-bit Bilevel Gray 23.98MB 0.218u 0:02.118
identify.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/887.
PS C:\>
Could this be related to my issue with converting the entire document?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Multi-page tiff to single page tiff - crashing Windows

Post by Bonzo »

Searching for tag 292 I get:
TIFF Tag T4Option

IFD
Image

Code
292 (hex 0x0124)

Name
T4Options

LibTiff name
TIFFTAG_GROUP3OPTIONS

Type
LONG

Count
1

Default
0 (basic 1-dimensional coding)

Description

Options for Group 3 Fax compression

This field is made up of a set of 32 flag bits. Unused bits must be set to 0. Bit 0 is the low-order bit.

The specification defines these bits:

Bit 0 is 1 for 2-dimensional coding (otherwise 1-dimensional is assumed). For 2-D coding, if more than one strip is specified, each strip must begin with a 1-dimensionally coded line. That is, RowsPerStrip should be a multiple of Parameter K, as documented in the CCITT specification.
Bit 1 is 1 if uncompressed mode is used.
Bit 2 is 1 if fill bits have been added as necessary before EOL codes such that EOL always ends on a byte boundary, thus ensuring an EOL-sequence of 1 byte preceded by a zero nibble: xxxx-0000 0000-0001.

LibTiff defines these bits as follows:

GROUP3OPT_2DENCODING = 1;
GROUP3OPT_UNCOMPRESSED = 2;
GROUP3OPT_FILLBITS = 4;
So I would guess the tif file is not in a format Imagemagick likes. You could try generating the tif with some other software and see what you get.
I suppose this could be an indication of the problem: Options for Group 3 Fax compression
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multi-page tiff to single page tiff - crashing Windows

Post by fmw42 »

The warnings are not errors. They just identify that IM does not recognize some custom tag in the file. You can avoid getting the messages by adding -quit right after convert and before the input image.

Looks like the file works fine. I suspect it is just taking longer to process all 683 pages than you might think in terms of reading them all in and writing them all out
Post Reply