1

I was at the library scanning pages of old newspaper articles and the microfilm scanner generated a TIFF stack. Now I am back home I thought this was going to be easier but nothing sees past frame zero. Is there a way to use convert from command line to separate all the images? Just running convert crashes.

jonathan@weinraub:~$ convert nyt_1980_12_30.tif nyt%d.png
Killed

2016-03-11T09:32:32-05:00 0:04.850 4.420u 6.8.9 Resource convert[1699]: resource.c/AcquireMagickResource/279/Resource Area: 119MB/119MB/4.2005GB 2016-03-11T09:32:32-05:00 0:04.850 4.420u 6.8.9 Resource convert[1699]: resource.c/AcquireMagickResource/279/Resource Memory: 119MB/1.1085GiB/1.956GiB 2016-03-11T09:32:32-05:00 0:04.850 4.420u 6.8.9 Cache convert[1699]: cache.c/OpenPixelCache/3606/Cache open nyt_1980_12_30.tif[9] (Heap Memory, 3400x4376 113.5MiB) 2016-03-11T09:32:32-05:00 0:04.850 4.420u 6.8.9 Resource convert[1699]: resource.c/AcquireMagickResource/279/Resource Memory: 59.51MB/1.164GiB/1.956GiB 2016-03-11T09:32:32-05:00 0:04.850 4.420u 6.8.9 Exception convert[1699]: tiff.c/TIFFWarnings/861/Exception Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software. OJPEGSetupDecode' Killed

jonathan@weinraub:~$ which convert
/usr/bin/convert
jonathan@weinraub:~$ convert
Version: ImageMagick 6.8.9-9 Q16 x86_64 2015-01-05     http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl     lzma openexr pangocairo png tiff wmf x xml zlib

Usage: convert [options ...] file [ [options ...] file ...] [options ...] file

Whats interesting, I tried on my RHEL server and I got different errors and it failed:

update:

16:55:40 0:36 34.100u 6.2.8 Cache convert[27230]: cache.c/DestroyCacheInfo/1763/Cache destroy nyt_1980_12_30.tif[10] 16:55:40 0:36 34.120u 6.2.8 Resource convert[27230]: resource.c/RelinquishMagickResource/801/Resource Memory: 1.1e+02mb/1.1e+02mb/5.9gb 16:55:40 0:36 34.120u 6.2.8 Cache convert[27230]: cache.c/DestroyCacheInfo/1763/Cache destroy nyt_1980_12_30.tif[11] 16:55:40 0:36 34.150u 6.2.8 Resource convert[27230]: resource.c/RelinquishMagickResource/801/Resource Memory: 1.1e+02mb/0/5.9gb 16:55:40 0:36 34.150u 6.2.8 Cache convert[27230]: cache.c/DestroyCacheInfo/1763/Cache destroy nyt_1980_12_30.tif[12] convert: nyt_1980_12_30.tif: unknown field with tag 512 (0x200) encountered. TIFFReadDirectory'. convert: nyt_1980_12_30.tif: unknown field with tag 513 (0x201) encountered. TIFFReadDirectory'. convert: nyt_1980_12_30.tif: unknown field with tag 514 (0x202) encountered. TIFFReadDirectory'. convert: nyt_1980_12_30.tif: unknown field with tag 519 (0x207) encountered. TIFFReadDirectory'. convert: nyt_1980_12_30.tif: unknown field with tag 520 (0x208) encountered. TIFFReadDirectory'.

I used Ifranview in windows at work and i got it converted in the end. But, I like to know why now on two systems, debian and rhel, it is failing.

Jonathan Weinraub
  • 625
  • 1
  • 8
  • 13

2 Answers2

2

Assuming TIFF file is not splitable via imagemagick due to outdated jpeg format used as compression

Assuming a platform like Debian or Ubuntu

use the libtiff-tools package that supplies the utility tiffsplit

sudo apt-get install libtiff-tools
tiffsplit problematicfile.tif file

edit

JPEG is a kind of compression that TIFF supports. Imagemagick seems to have problems with it sometimes. if the split files are still problematic, then the compression can be altered with a different libtiff tool, tiffcpwhich can use one of several other compression types with its -c switch

tiffcp -c lzw jpegedfile.tif  lzwedfile.tif

promoted from the comments (@Mint)

Technote on why compression sometimes fails

infixed
  • 809
  • 7
  • 10
  • Note on why old jpeg format was messed up http://www.remotesensing.org/libtiff/TIFFTechNote2.html – infixed Mar 12 '16 at 01:21
  • 1
    Unless I used it wrong, I got `TIFFReadRawStrip: Compression scheme does not support access to raw uncompressed data.` – Jonathan Weinraub Mar 12 '16 at 19:32
  • was that on the tiffsplit or tiffcp? tiffcp has a `-c none` switch. You could try that on the whole stack before splitting. Sounds like that jpeg compression was a bad idea for the programmer, even if they set it for lossless level of quality – infixed Mar 13 '16 at 06:17
  • That did the trick. Interestingly enough, using the `tiffcp` then the `tiffsplit` separated the file into 14 tiff files. using convert on the `tiffscp` only generated two PNGs before being killed – Jonathan Weinraub Mar 13 '16 at 06:51
  • 1
    For anyone looking to read the TIFFTechNote2.html page from the first comment, it's still up on the internet archive (as remotesensing.org has closed down) https://web.archive.org/web/20160303165607/http://www.remotesensing.org/libtiff/TIFFTechNote2.html – Mint Aug 09 '19 at 08:22
0

See How to split a multipage TIFF file on Windows?

but use the convert to make PNGs instead

convert multipage.tif single%d.png
infixed
  • 809
  • 7
  • 10
  • It still gets killed. I edited my original question to show. – Jonathan Weinraub Mar 11 '16 at 05:03
  • Maybe turning on debug logging will provide some insight `convert -debug all nyt_1980_12_30.tif nyt%d.png` – infixed Mar 11 '16 at 13:08
  • you might even verify that your path is such that running `convert` is imagemagick's convert. A verb like convert may be used by something else as a command name – infixed Mar 11 '16 at 13:12
  • Wow, if that's an abort on a depreciated feature of JPEG, that's pretty hash. – infixed Mar 11 '16 at 21:31
  • People were complaining about it here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=16155 – infixed Mar 11 '16 at 21:31
  • As a possible work around, perhaps expanding to jpegs won't decompress the jpgs, and they will just be split out verbatim. That might skip over the decompression error. Then you can try other tools to convert to png. – infixed Mar 11 '16 at 21:33
  • Is this TIFF file something you are willing to share online? IIRC it was about a GB. too large for email, but maybe you have someplace you can leave it out for download – infixed Mar 11 '16 at 21:52
  • Thats the thing, its only 14 pages long or so, 44 meg. Not sure why it is failing. I tried to use jpg and it still fails. As well as on rhel where it then gives me `convert: Sorry, requested compression method is not configured. `nyt_1980_12_30.tif'.` – Jonathan Weinraub Mar 11 '16 at 22:02
  • Well, that's a better error message than 'Killed' If I had a copy I thought I might try throwing perl Imager::File::TIFF at it, or seeing if libtiff in C chokes on it – infixed Mar 11 '16 at 22:09
  • If you do a `strings` on it, do you see the "JPEG" that magic-numbers the JPEG header for each image. If so, a dirty way to split it might be to just hack out chunks based on the address of those boundaries (darn it `strings` looks for 5 characters in a row I think. use `xxd` and search for JPEG instead) – infixed Mar 11 '16 at 22:15
  • now after thinking about it during a drive home, I bet the JPEGs are preview images, while the data you want is in actual TIFF image areas. I'm off to see if there is some way to strip previews from TIFFs – infixed Mar 11 '16 at 22:50
  • that makes sense, i was wondering why there is jpeg data in a lossless file format. – Jonathan Weinraub Mar 11 '16 at 22:51