convert extraction from tif file causes out of memory

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
mmkiel
Posts: 2
Joined: 2019-03-07T07:31:54-07:00
Authentication code: 1152

convert extraction from tif file causes out of memory

Post by mmkiel »

Hello,

I am trying to extract specific pages from a tif-file within a cron job. This job first checks for the pages to extract and stores the page numbers, then passes those values on to ImageMagick. Usually this worked fine so far, but now I have hit an inconvenience with one file, resultuing in the job simply to crash. This tif-file has 242 pages, 200x200 dpi, 1656x2338 px with 1 bit color depth. The whole file is just about 6.6 MB in size (CCITT T.6 compressed). I am using the convert with Version: ImageMagick 7.0.7-34 Q16 x86_64 20180520

The job is effectively just running this command:

convert -compress Group4 infile.tif[0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,50,52,53,54,55,56,58,60,62,63,64,66,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,100,102,103,104,105,106,108,109,110,111,112,113,114,116,118,119,120,121,122,124,126,127,128,130,131,132,133,134,136,138,139,140,141,142,143,144,145,146,147,148,149,150,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,178,180,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,236,237,238,240] outfile.tif

But running this causes the program to allocate way more than the 4GB ram this server provides. Is there any way to limit the processing to only the minimum amount of memory required for a black and white file, or is there any other tool better suited to this task than convert?

Thank you,
Marc
mmkiel
Posts: 2
Joined: 2019-03-07T07:31:54-07:00
Authentication code: 1152

Re: convert extraction from tif file causes out of memory

Post by mmkiel »

I found a solution, and faster than expected! :roll:
Although the convert can (and does) get me the nessecary information on the pages I require to extract, convert is rather overkill for the last step of the process. I will now use libtiff's tiffcp instead to extract the pages into a new file, as this should suffice for this.

Sometimes it would seem to help asking and rethinking the whole thing... Sorry to bother. :)
Post Reply