Page 1 of 1

Convert Multipage tiff failing

Posted: 2013-10-04T13:49:04-07:00
by mhansche
I am using the following ImageMagick version on Linux (Red Hat Enterprise Linux ES release 4 (Nahant Update 5))
Version: ImageMagick 6.8.6-9 2013-08-28 Q16 http://www.imagemagick.org
I have also tried it on the following:
Linux server running Cent OS (CentOS release 6.4 (Final))
Version: ImageMagick 6.8.6-9 2013-08-29 Q16 http://www.imagemagick.org

I have the problem on both servers. It appears that Imagemagick will generate 64mb temp files until it fills up the tmp directory and then hangs.

Doesn't seem to matter the filesize itself. The problem is that I need to set rowsperstrip and image height both while either converting the compression or not. I'm converting to / from the following formats

group 4 fax to group 4 fax
group 4 fax to group 3 fax
group 3 fax to group 4 fax
group 3 fax to group 3 fax
pdf to group 3 fax
pdf to group 4 fax

The following are two of the commands that hang. These are attempting to set the conversion values for a group 4 tiff file.
convert -geometry x2200 -define tiff:rows-per-strip=2200 -set tiff:software "Software version 3.0" Testing123.tif Testing123-g42200.tif
convert -geometry x2200 -define tiff:rows-per-strip=2200 -compress Group4 -set tiff:software "Software version 3.0" Testing123.tif Testing123-g42200.tif
convert -geometry x2201 -define tiff:rows-per-strip=2201 -compress Fax -set tiff:software "Software version 3.0" Testing123.tif Testing123-g32201.tif

I've tried everything I can think of and googled the hell out of this and can't find anything that matches the problem I am having.

Any help would be appreciated. File I am testing with is here http://aces4hire.com/wscopy/Testing123.tif

Re: Convert Multipage tiff failing

Posted: 2013-10-04T13:59:45-07:00
by fmw42
try putting the input image right after the convert. Also -geometry is doing nothing! Are you trying to resize to image or chance the virtual canvas offset? If the former, then use -resize, if the latter then use -repage.

Your image has over 200 layers. That might cause IM to run out of memory.

see
http://www.imagemagick.org/Usage/files/#massive

I am not expert on this, but if I run your command as follows according to that page and add -monitor and time, I can see the progress which is slow. But it seems to be working.


time env MAGICK_TMPDIR=/data nice -5 \
convert -monitor -limit memory 32 -limit map 32 Testing123.tif \
-define tiff:rows-per-strip=2200 -compress Group4 -set tiff:software "Software version 3.0" testing.tif

Re: Convert Multipage tiff failing

Posted: 2013-10-04T15:14:59-07:00
by mhansche
@fmw42 - Thanks for your responses

I'm trying to resize the image to either 2200 or 2201 height (as well as set rowsperstrip and compression)
I've used -geometry to set the height of the image. This works fine on multipage tiffs that have less pages without a problem (at least the height property changes). However, I removed it just to try it and it didn't help. Basically the same result, it fills the tmp folder until it is out of space with multiple 64mb tmp files. See image.

Image

I also tried running your exact command to monitor and limit memory and had nearly the same results. It actually eventually generated the output file but when I attempt to open it in IranView tiffviewer it reports there are 607 pages. However, only the first 138 are visible then it goes to black and there are no more page numbers so I assume it is corrupt.

There are actually 238 pages in the test file, but there will be files that have 500 pages or more. This is just a test file. So if I can't get this working I'm really SOL.

Re: Convert Multipage tiff failing

Posted: 2013-10-04T15:27:03-07:00
by fmw42
I opened your file and got a count of the pages and IM only reports 234.

I am still running the test to get a timing and will report back when completed.

If you want to resize, then use -resize not -geometry. That, in principle only works during composition and only on the last image. See

http://www.imagemagick.org/Usage/layers/#composition

"Now the "-geometry" is is a very special operator that not only sets an overlay position for the next "-composite" operation, it will also "-resize" the last image (and only the last image) in the current image sequence."

In general, -geometry is setting for an offset when doing convert image1 image2 -geometry ... -compose over -composite result.

I have never seen it used just to resize a single image (with or without layers).


Perhaps you are confusing it with the image geometry reference at -resize

http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry

But that is a completely different thing.



Here is what I get:

time env MAGICK_TMPDIR=/data nice -5 \
convert -monitor -limit memory 32 -limit map 32 Testing123.tif -define tf:rows-per-strip=2200 -compress Group4 -set tiff:software "Software version 3.0" testing.tif

Code: Select all

load image[Testing123.tif]: 3300 of 3301, 100% complete
load images[Testing123.tif]: 1 of 2, 100% complete
load images[Testing123.tif]: 2 of 3, 100% complete
load images[Testing123.tif]: 3 of 4, 100% complete
load images[Testing123.tif]: 4 of 5, 100% complete
load images[Testing123.tif]: 5 of 6, 100% complete
load images[Testing123.tif]: 6 of 7, 100% complete
load images[Testing123.tif]: 7 of 8, 100% complete
load images[Testing123.tif]: 8 of 9, 100% complete
load images[Testing123.tif]: 9 of 10, 100% complete
load images[Testing123.tif]: 10 of 11, 100% complete
load images[Testing123.tif]: 11 of 12, 100% complete
load images[Testing123.tif]: 12 of 13, 100% complete
load images[Testing123.tif]: 13 of 14, 100% complete
load images[Testing123.tif]: 14 of 15, 100% complete
load images[Testing123.tif]: 15 of 16, 100% complete
load images[Testing123.tif]: 16 of 17, 100% complete
load images[Testing123.tif]: 17 of 18, 100% complete
load images[Testing123.tif]: 18 of 19, 100% complete
load images[Testing123.tif]: 19 of 20, 100% complete
load images[Testing123.tif]: 20 of 21, 100% complete
load images[Testing123.tif]: 21 of 22, 100% complete
load images[Testing123.tif]: 22 of 23, 100% complete
load images[Testing123.tif]: 23 of 24, 100% complete
load images[Testing123.tif]: 24 of 25, 100% complete
load images[Testing123.tif]: 25 of 26, 100% complete
load images[Testing123.tif]: 26 of 27, 100% complete
load images[Testing123.tif]: 27 of 28, 100% complete
load images[Testing123.tif]: 28 of 29, 100% complete
load images[Testing123.tif]: 29 of 30, 100% complete
load images[Testing123.tif]: 30 of 31, 100% complete
load images[Testing123.tif]: 31 of 32, 100% complete
load images[Testing123.tif]: 32 of 33, 100% complete
load images[Testing123.tif]: 33 of 34, 100% complete
load images[Testing123.tif]: 34 of 35, 100% complete
load images[Testing123.tif]: 35 of 36, 100% complete
load images[Testing123.tif]: 36 of 37, 100% complete
load images[Testing123.tif]: 37 of 38, 100% complete
load images[Testing123.tif]: 38 of 39, 100% complete
load images[Testing123.tif]: 39 of 40, 100% complete
load images[Testing123.tif]: 40 of 41, 100% complete
load images[Testing123.tif]: 41 of 42, 100% complete
load images[Testing123.tif]: 42 of 43, 100% complete
load images[Testing123.tif]: 43 of 44, 100% complete
load images[Testing123.tif]: 44 of 45, 100% complete
load images[Testing123.tif]: 45 of 46, 100% complete
load images[Testing123.tif]: 46 of 47, 100% complete
load images[Testing123.tif]: 47 of 48, 100% complete
load images[Testing123.tif]: 48 of 49, 100% complete
load images[Testing123.tif]: 49 of 50, 100% complete
load images[Testing123.tif]: 50 of 51, 100% complete
load images[Testing123.tif]: 51 of 52, 100% complete
load images[Testing123.tif]: 52 of 53, 100% complete
load images[Testing123.tif]: 53 of 54, 100% complete
load images[Testing123.tif]: 54 of 55, 100% complete
load images[Testing123.tif]: 55 of 56, 100% complete
load images[Testing123.tif]: 56 of 57, 100% complete
load images[Testing123.tif]: 57 of 58, 100% complete
load images[Testing123.tif]: 58 of 59, 100% complete
load images[Testing123.tif]: 59 of 60, 100% complete
load images[Testing123.tif]: 60 of 61, 100% complete
load images[Testing123.tif]: 61 of 62, 100% complete
load images[Testing123.tif]: 62 of 63, 100% complete
load images[Testing123.tif]: 63 of 64, 100% complete
load images[Testing123.tif]: 64 of 65, 100% complete
load images[Testing123.tif]: 65 of 66, 100% complete
load images[Testing123.tif]: 66 of 67, 100% complete
load images[Testing123.tif]: 67 of 68, 100% complete
load images[Testing123.tif]: 68 of 69, 100% complete
load images[Testing123.tif]: 69 of 70, 100% complete
load images[Testing123.tif]: 70 of 71, 100% complete
load images[Testing123.tif]: 71 of 72, 100% complete
load images[Testing123.tif]: 72 of 73, 100% complete
load images[Testing123.tif]: 73 of 74, 100% complete
load images[Testing123.tif]: 74 of 75, 100% complete
load images[Testing123.tif]: 75 of 76, 100% complete
load images[Testing123.tif]: 76 of 77, 100% complete
load images[Testing123.tif]: 77 of 78, 100% complete
load images[Testing123.tif]: 78 of 79, 100% complete
load images[Testing123.tif]: 79 of 80, 100% complete
load images[Testing123.tif]: 80 of 81, 100% complete
load images[Testing123.tif]: 81 of 82, 100% complete
load images[Testing123.tif]: 82 of 83, 100% complete
load images[Testing123.tif]: 83 of 84, 100% complete
load images[Testing123.tif]: 84 of 85, 100% complete
load images[Testing123.tif]: 85 of 86, 100% complete
load images[Testing123.tif]: 86 of 87, 100% complete
load images[Testing123.tif]: 87 of 88, 100% complete
load images[Testing123.tif]: 88 of 89, 100% complete
load images[Testing123.tif]: 89 of 90, 100% complete
load images[Testing123.tif]: 90 of 91, 100% complete
load images[Testing123.tif]: 91 of 92, 100% complete
load images[Testing123.tif]: 92 of 93, 100% complete
load images[Testing123.tif]: 93 of 94, 100% complete
load images[Testing123.tif]: 94 of 95, 100% complete
load images[Testing123.tif]: 95 of 96, 100% complete
load images[Testing123.tif]: 96 of 97, 100% complete
load images[Testing123.tif]: 97 of 98, 100% complete
load images[Testing123.tif]: 98 of 99, 100% complete
load images[Testing123.tif]: 99 of 100, 100% complete
load images[Testing123.tif]: 100 of 101, 100% complete
load images[Testing123.tif]: 101 of 102, 100% complete
load images[Testing123.tif]: 102 of 103, 100% complete
load images[Testing123.tif]: 103 of 104, 100% complete
load images[Testing123.tif]: 104 of 105, 100% complete
load images[Testing123.tif]: 105 of 106, 100% complete
load images[Testing123.tif]: 106 of 107, 100% complete
load images[Testing123.tif]: 107 of 108, 100% complete
load images[Testing123.tif]: 108 of 109, 100% complete
load images[Testing123.tif]: 109 of 110, 100% complete
load images[Testing123.tif]: 110 of 111, 100% complete
load images[Testing123.tif]: 111 of 112, 100% complete
load images[Testing123.tif]: 112 of 113, 100% complete
load images[Testing123.tif]: 113 of 114, 100% complete
load images[Testing123.tif]: 114 of 115, 100% complete
load images[Testing123.tif]: 115 of 116, 100% complete
load images[Testing123.tif]: 116 of 117, 100% complete
load images[Testing123.tif]: 117 of 118, 100% complete
load images[Testing123.tif]: 118 of 119, 100% complete
load images[Testing123.tif]: 119 of 120, 100% complete
load images[Testing123.tif]: 120 of 121, 100% complete
load images[Testing123.tif]: 121 of 122, 100% complete
load images[Testing123.tif]: 122 of 123, 100% complete
load images[Testing123.tif]: 123 of 124, 100% complete
load images[Testing123.tif]: 124 of 125, 100% complete
load images[Testing123.tif]: 125 of 126, 100% complete
load images[Testing123.tif]: 126 of 127, 100% complete
load images[Testing123.tif]: 127 of 128, 100% complete
load images[Testing123.tif]: 128 of 129, 100% complete
load images[Testing123.tif]: 129 of 130, 100% complete
load images[Testing123.tif]: 130 of 131, 100% complete
load images[Testing123.tif]: 131 of 132, 100% complete
load images[Testing123.tif]: 132 of 133, 100% complete
load images[Testing123.tif]: 133 of 134, 100% complete
load images[Testing123.tif]: 134 of 135, 100% complete
load images[Testing123.tif]: 135 of 136, 100% complete
load images[Testing123.tif]: 136 of 137, 100% complete
load images[Testing123.tif]: 137 of 138, 100% complete
load images[Testing123.tif]: 138 of 139, 100% complete
load images[Testing123.tif]: 139 of 140, 100% complete
load images[Testing123.tif]: 140 of 141, 100% complete
load images[Testing123.tif]: 141 of 142, 100% complete
load images[Testing123.tif]: 142 of 143, 100% complete
load images[Testing123.tif]: 143 of 144, 100% complete
load images[Testing123.tif]: 144 of 145, 100% complete
load images[Testing123.tif]: 145 of 146, 100% complete
load images[Testing123.tif]: 146 of 147, 100% complete
load images[Testing123.tif]: 147 of 148, 100% complete
load images[Testing123.tif]: 148 of 149, 100% complete
load images[Testing123.tif]: 149 of 150, 100% complete
load images[Testing123.tif]: 150 of 151, 100% complete
load images[Testing123.tif]: 151 of 152, 100% complete
load images[Testing123.tif]: 152 of 153, 100% complete
load images[Testing123.tif]: 153 of 154, 100% complete
load images[Testing123.tif]: 154 of 155, 100% complete
load images[Testing123.tif]: 155 of 156, 100% complete
load images[Testing123.tif]: 156 of 157, 100% complete
load images[Testing123.tif]: 157 of 158, 100% complete
load images[Testing123.tif]: 158 of 159, 100% complete
load images[Testing123.tif]: 159 of 160, 100% complete
load images[Testing123.tif]: 160 of 161, 100% complete
load images[Testing123.tif]: 161 of 162, 100% complete
load images[Testing123.tif]: 162 of 163, 100% complete
load images[Testing123.tif]: 163 of 164, 100% complete
load images[Testing123.tif]: 164 of 165, 100% complete
load images[Testing123.tif]: 165 of 166, 100% complete
load images[Testing123.tif]: 166 of 167, 100% complete
load images[Testing123.tif]: 167 of 168, 100% complete
load images[Testing123.tif]: 168 of 169, 100% complete
load images[Testing123.tif]: 169 of 170, 100% complete
load images[Testing123.tif]: 170 of 171, 100% complete
load images[Testing123.tif]: 171 of 172, 100% complete
load images[Testing123.tif]: 172 of 173, 100% complete
load images[Testing123.tif]: 173 of 174, 100% complete
load images[Testing123.tif]: 174 of 175, 100% complete
load images[Testing123.tif]: 175 of 176, 100% complete
load images[Testing123.tif]: 176 of 177, 100% complete
load images[Testing123.tif]: 177 of 178, 100% complete
load images[Testing123.tif]: 178 of 179, 100% complete
load images[Testing123.tif]: 179 of 180, 100% complete
load images[Testing123.tif]: 180 of 181, 100% complete
load images[Testing123.tif]: 181 of 182, 100% complete
load images[Testing123.tif]: 182 of 183, 100% complete
load images[Testing123.tif]: 183 of 184, 100% complete
load images[Testing123.tif]: 184 of 185, 100% complete
load images[Testing123.tif]: 185 of 186, 100% complete
load images[Testing123.tif]: 186 of 187, 100% complete
load images[Testing123.tif]: 187 of 188, 100% complete
load images[Testing123.tif]: 188 of 189, 100% complete
load images[Testing123.tif]: 189 of 190, 100% complete
load images[Testing123.tif]: 190 of 191, 100% complete
load images[Testing123.tif]: 191 of 192, 100% complete
load images[Testing123.tif]: 192 of 193, 100% complete
load images[Testing123.tif]: 193 of 194, 100% complete
load images[Testing123.tif]: 194 of 195, 100% complete
load images[Testing123.tif]: 195 of 196, 100% complete
load images[Testing123.tif]: 196 of 197, 100% complete
load images[Testing123.tif]: 197 of 198, 100% complete
load images[Testing123.tif]: 198 of 199, 100% complete
load images[Testing123.tif]: 199 of 200, 100% complete
load images[Testing123.tif]: 200 of 201, 100% complete
load images[Testing123.tif]: 201 of 202, 100% complete
load images[Testing123.tif]: 202 of 203, 100% complete
load images[Testing123.tif]: 203 of 204, 100% complete
load images[Testing123.tif]: 204 of 205, 100% complete
load images[Testing123.tif]: 205 of 206, 100% complete
load images[Testing123.tif]: 206 of 207, 100% complete
load images[Testing123.tif]: 207 of 208, 100% complete
load images[Testing123.tif]: 208 of 209, 100% complete
load images[Testing123.tif]: 209 of 210, 100% complete
load images[Testing123.tif]: 210 of 211, 100% complete
load images[Testing123.tif]: 211 of 212, 100% complete
load images[Testing123.tif]: 212 of 213, 100% complete
load images[Testing123.tif]: 213 of 214, 100% complete
load images[Testing123.tif]: 214 of 215, 100% complete
load images[Testing123.tif]: 215 of 216, 100% complete
load images[Testing123.tif]: 216 of 217, 100% complete
load images[Testing123.tif]: 217 of 218, 100% complete
load images[Testing123.tif]: 218 of 219, 100% complete
load images[Testing123.tif]: 219 of 220, 100% complete
load images[Testing123.tif]: 220 of 221, 100% complete
load images[Testing123.tif]: 221 of 222, 100% complete
load images[Testing123.tif]: 222 of 223, 100% complete
load images[Testing123.tif]: 223 of 224, 100% complete
load images[Testing123.tif]: 224 of 225, 100% complete
load images[Testing123.tif]: 225 of 226, 100% complete
load images[Testing123.tif]: 226 of 227, 100% complete
load images[Testing123.tif]: 227 of 228, 100% complete
load images[Testing123.tif]: 228 of 229, 100% complete
load images[Testing123.tif]: 229 of 230, 100% complete
load images[Testing123.tif]: 230 of 231, 100% complete
load images[Testing123.tif]: 231 of 232, 100% complete
load images[Testing123.tif]: 232 of 233, 100% complete
mogrify image[Testing123.tif]: 233 of 234, 100% complete
mogrify image[Testing123.tif]: 233 of 234, 100% complete
save images[testing.tif]: 41 of 234, 17% complete
convert: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/837.
real 46m3.749s
user 0m27.224s
sys 1m33.933s

The resulting image has 234 layers and I can open it in Mac Preview and see each layer. My result is http://www.fmwconcepts.com/misc_tests/d ... esting.tif

I am using an INTEL Mac Mini 2.66 GHz with 4GB memory ( and running IM 6.8.7.0 Q16 with 1 thread).

Re: Convert Multipage tiff failing

Posted: 2013-10-04T16:20:50-07:00
by mhansche
ok, I missed this line


Tried it again and I basically get the same info except at the end I get a bunch of repeated error lines (just showing one below) before the summary. I assume it repeated for the number of layers, but it surpassed the max lines that putty supports as displaying history.

Code: Select all

convert: Testing123.tif: unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/838.
convert: unable to extend cache `Testing123.tif': No space left on device @ error/cache.c/OpenPixelCache/3662.

real    2m27.397s
user    0m7.867s
sys     0m44.894s
I also got 234 layers that I could see but the file definitely went beyond that and it was black and showed no more page numbers. Anyway, if 234 pages is max, any ideas how I can successfully convert more layers/pages than that?

For example could I convert 230 pages at a time and then combine them all into one final tiff or will that not work either?
If I am up against a limit then I will have to find another tool if there is one. Do you know of any tool at all for linux to do what I need to do for 234+ pages? Client told me they may even have 2k pages, argh. I used libtiff to convert and it worked but I can't set size. I was able to set rowsperstrip and compression fine. This obviously may be for another forum another place but I've been fighting with this for a long time so if you've got any more ideas I'd appreciate it.

Re: Convert Multipage tiff failing

Posted: 2013-10-04T16:31:39-07:00
by mhansche
My mistake, tiffcp actually also has the 234 page limit (I think imagemagick uses this?) but it converts the 234 pages within 3 seconds rather than minutes. I guess I hadn't tested with > 234 pages yet.

Anyway, tiffcp doesn't appear to give me resize capability.

And I don't see a way to convert using either tool a subset of pages so even if I had a 500 page file, I don't see how I could convert 0-233, 234-467, 468-500 and then combine them. Am I missing something you might know of?

Re: Convert Multipage tiff failing

Posted: 2013-10-04T17:29:05-07:00
by fmw42
try this:

create two new directories (say folder1 and folder2)

cd to directory holding your image

convert image.tiff +adjoin path2/folder1/image_%04d.tiff

cd to folder1

mogrify -path path2/folder2 -format tiff -resize x2200 \
-define tiff:rows-per-strip=2200 -compress Group4 -set tiff:software "Software version 3.0" *.tiff

cd to folder2

convert *.tiff path2originalimage/newimage.tiff

remove folder1 and folder2 (rm -rf ...)


However, if libtiff has a limit on the number of layers, then IM will not be able to put all the images back into a layered tiff, because it relies upon libtiff.