#425778 libtiff-tools: tiff2pdf produce unreadable file if TIFF is compressed with JPEG

Package:
libtiff-tools
Source:
tiff
Description:
TIFF manipulation and conversion tools
Submitter:
Giuseppe Sacco
Date:
2019-10-03 19:42:14 UTC
Severity:
important
#425778#5
Date:
2007-05-23 21:53:35 UTC
From:
To:
Converting TIFF files to PDF does not work when TIFF is compressed using JPEG.
A tiff file and its pdf counterpart are available at
http://eppesuigoccas.homedns.org/~giuseppe/libtiff-tools.tiff2pdf.bug.tar.bz2

I checked the tiff file:

giuseppe@scarafaggio:~/Desktop$ tiffinfo -D scontrini-maggio-infor-bm.tiff
TIFF Directory at offset 0x8 (8)
  Image Width: 1248 Image Length: 1753
  Resolution: 150, 150 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: min-is-black
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 1
  Rows/Strip: 8
  Planar Configuration: single image plane
  Software: Neos
  DateTime: 2007:05:23 23:24:32
  Artist: Giuseppe Sacco (giuseppe)
  HostComputer: scarafaggio

and there were no errors reported (please note the -D option).
Then I converted the TIFF file to PDF as shown here:

giuseppe@scarafaggio:~/Desktop$ tiff2pdf -o scontrini-maggio-infor-bm.pdf scontrini-maggio-infor-bm.tiff

and then I run xpdf in order to disply it. xpdf show an empty page and it prints this error:

giuseppe@scarafaggio:~/Desktop$ xpdf scontrini-maggio-infor-bm.pdf
Error (1388): Bad DCT data: incorrect restart marker
Warning: Attempt to remove nonexistent passive grab

Using evince as an alternative program to display the PDF file print a different error message:

giuseppe@scarafaggio:~/Desktop$ evince scontrini-maggio-infor-bm.pdf
Error: Could not find start of jpeg data

converting the PDF file to PostScript usng ghostscript display a different error:

giuseppe@scarafaggio:~/Desktop$ pdf2ps scontrini-maggio-infor-bm.pdf scontrini-maggio-infor-bm.ps

   **** Warning: File has insufficient data for an image.

   **** This file had errors that were repaired or ignored.
   **** The file was produced by:
   **** >>>> libtiff / tiff2pdf - 20060323 / d <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

changing the tiff compression algorithm from JPEG to LZW and the converting
the resulting TIFF to PDF does work:

giuseppe@scarafaggio:~/Desktop$ tiffcp -c lzw scontrini-maggio-infor-bm.tiff scontrini-maggio-infor-bm.tiff.2
giuseppe@scarafaggio:~/Desktop$ tiffinfo  scontrini-maggio-infor-bm.tiff.2
TIFF Directory at offset 0x34152 (213330)
  Image Width: 1248 Image Length: 1753
  Resolution: 150, 150 pixels/inch
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: min-is-black
  YCbCr Subsampling: 2, 2
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 8
  Planar Configuration: single image plane
  Software: Neos
  DateTime: 2007:05:23 23:24:32
  Artist: Giuseppe Sacco (giuseppe)
  HostComputer: scarafaggio
giuseppe@scarafaggio:~/Desktop$ tiff2pdf -o x.pdf scontrini-maggio-infor-bm.tiff.2
giuseppe@scarafaggio:~/Desktop$ xpdf x.pdf
Warning: Attempt to remove nonexistent passive grab

Bye,
Giuseppe

#425778#10
Date:
2007-07-10 22:05:28 UTC
From:
To:
Giuseppe Sacco <eppesuig@debian.org> wrote:

Hello.  Thanks for reporting this problem.  I am able to reproduce it
and will report it upstream and track its progress.

I really apologize for waiting so long to respond to this, especially
considering that you sponsored several of my uploads while I was still
waiting to become a DD! :-) My life has been busy (in a good way), but
I'm trying to get caught up on by debian work now.

Hopefully I can upload a new patched version soon.

#425778#17
Date:
2008-06-08 01:43:25 UTC
From:
To:
forwarded 425778 http://bugzilla.maptools.org/show_bug.cgi?id=1893
thanks

The original bug report got lost when tiff upstream lost its bugzilla
database.  I have re-entered the bug upstream.  This is its new URL.

#425778#24
Date:
2008-06-08 02:49:55 UTC
From:
To:
I've verified that this bug still applies to the current beta of
libtiff 4.0.0, so even though I have backported the largely rewritten
tiff2pdf, the problem has not gone away.  Hopefully it will get some
attention upstream.

In the mean time, though I'm sure you've already figured this out,
I'll point out that you can convert this tiff to PDF using "convert"
from ImageMagick.  It does a better job of creating PDF files than
tiff2pdf, which is a very buggy piece of software.

#425778#27
Date:
2008-06-08 02:49:55 UTC
From:
To:
I've verified that this bug still applies to the current beta of
libtiff 4.0.0, so even though I have backported the largely rewritten
tiff2pdf, the problem has not gone away.  Hopefully it will get some
attention upstream.

In the mean time, though I'm sure you've already figured this out,
I'll point out that you can convert this tiff to PDF using "convert"
from ImageMagick.  It does a better job of creating PDF files than
tiff2pdf, which is a very buggy piece of software.

#425778#32
Date:
2015-02-27 23:43:25 UTC
From:
To:
Unfortunately using convert or other tools that recompress the jpeg end up
with a generational quality loss, which most people would probably want to
avoid.