Bug 1960 - tiff2pdf: Line shift in right tiff tiles of output pdf (if jpeg compressed tiles in input tiff)
: tiff2pdf: Line shift in right tiff tiles of output pdf (if jpeg compressed ti...
Status: RESOLVED LATER
: libtiff
default
: 3.9.0
: All Linux
: P2 normal
: ---
Assigned To:
:
:
: migrated_to_gitlab
:
:
  Show dependency treegraph
 
Reported: 2008-10-31 11:36 by
Modified: 2019-10-01 14:19 (History)


Attachments
The input TIFF file (with jpeg compressed tiles), which produces the problem (523.92 KB, image/tiff)
2008-10-31 11:45, Burkhard
Details
The PDF output created by: tiff2pdf -o cp-tiled.pdf cp-tiled.tif (551.89 KB, application/pdf)
2008-10-31 11:47, Burkhard
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2008-10-31 11:36:23
I have the following  problem creating a pdf file with tiff2pdf (v 1.37.2.6
2008/09/03): 

Using a tiled input tiff file consisting of jpeg-encoded tiles, all the tiles on
the right edge are broken (the lines are shifted against each other). The
problem only appears, if the image width is not a multiple of the tilewidth,
which means that every last horizontal tile does not have the full width. 

It seems that the displacement of the lines behaves as follows:
If the rightmost tiles of the input tiff contain N columns less than the others,
each line in those tiles in the output pdf is N pixels shifted to the right in
relation to the line above.

The problem only occurs with jpeg compressed, tiled input tiff.
------- Comment #1 From 2008-10-31 11:45:47 -------
Created an attachment (id=272) [details]
The input TIFF file (with jpeg compressed tiles), which produces the problem
------- Comment #2 From 2008-10-31 11:47:58 -------
Created an attachment (id=273) [details]
The PDF output created by: tiff2pdf -o cp-tiled.pdf cp-tiled.tif
------- Comment #3 From 2010-08-29 19:25:40 -------
I think what is going on here is that each JPEG-compressed tile is of
dimensions 1024x64, ie, the nominal tile size (which is what is specified by
TIFF Tech Note #2).  However, for the tiles at right and bottom edges,
tiff2pdf.c emits /Width 590 and/or /Height 41 in the object definitions in the
PDF file.  The messed-up display is consistent with the idea that the PDF
decoder is expecting /Width and /Height to match the actual raster dimensions
of the compressed data.

I think the correct fix is to emit /Width and /Height matching the logical tile
dimensions in all cases, and then make use of a Postscript graphical masking
operator to hide the garbage data at right/bottom.  The latter is unfortunately
far beyond my Postscript-fu.
------- Comment #4 From 2010-08-29 19:43:11 -------
I did a quick experiment with hacking tiff2pdf.c to produce the /Width and
/Length as suggested above.  This produced the effects I expected: in evince,
instead of complete garbage for the edge tiles, we see the expected data out to
the intended image edge, and then junk beyond that.  With this particular image
the "junk" is a repetition of some of the image data, which no doubt tells us
something about the buffer layout used by the image creator.

Interestingly, this display matches what I see in Apple's Preview for *either*
version of the output file.  So apparently Apple's implementation doesn't pay
much mind to the /Width and /Length tags, and just decompresses and displays
the image data no matter what.  The graphical masking hack would be the only
way to make that work as desired.
------- Comment #5 From 2019-10-01 14:19:19 -------
Bugzilla is no longer used for tracking libtiff issues. Remaining open tickets,
such as this one, have been migrated to the libtiff GitLab instance at
https://gitlab.com/libtiff/libtiff/issues .

The migrated tickets have their summary prefixed with [BZ#XXXX] where XXXX is
the initial Bugzilla issue number.