This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 52462 - tifftopnm ignores photometric interpretation
tifftopnm ignores photometric interpretation
Product: Red Hat Public Beta
Classification: Retired
Component: netpbm (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2001-08-23 18:07 EDT by Jay Berkenbilt
Modified: 2015-03-04 20:09 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-09-03 09:08:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:

Attachments (Terms of Use)
tiff file with min-is-white photometric interpretation (462 bytes, image/tiff)
2001-08-23 18:07 EDT, Jay Berkenbilt
no flags Details
tiff file with min-is-black photometric interpretation (462 bytes, image/tiff)
2001-08-23 18:08 EDT, Jay Berkenbilt
no flags Details
patch to fix this problem (453 bytes, patch)
2001-08-23 18:32 EDT, Jay Berkenbilt
no flags Details | Diff

  None (edit)
Description Jay Berkenbilt 2001-08-23 18:07:02 EDT
Description of Problem:

tifftopnm ignores photometric interpretation when converting b/w tiff
files, at least those compressed with CCITT group 4.

Version-Release number of selected component (if applicable):

netpbm-progs-9.14.1 is what is in Roswell, but the bug exists in seawolf as
well.  The bug does not exist in RedHat 6.2.  I don't have anything between
seawolf and RedHat 6.2 to test against, so I don't know when the bug
initially appeared.

How Reproducible:


Steps to Reproduce:
1. I am attaching to this report two tiff files: min-is-black.tiff and
min-is-white.tiff.  These tiff files are both CCITT group 4 compressed
tiffs.  They are identical except for their photometric interpretation. 
You can view that information with tiffinfo.  Specifically, run tiffinfo on
both files and diff the results.  The photometric interpretation of a
bitotal tiff image tells the viewer whether to interpret a 0 pixel value as
white or black.  If you view these files with ee, you will see that
min-is-white.tiff has black text with a white background and that
min-is-black.tiff has white text with a black background.
2. Convert these two files to pbm files with tifftopnm:
tifftopnm min-is-black.tiff > min-is-black.pbm
tifftopnm min-is-white.tiff > min-is-white.pbm
Observe that both files show white text with a black background; i.e.,
tifftopnm ignored the photometric interpretation tag and treated both
images as if they had min-is-black photometric interpretation.
3. Now convert the two files to pbm using imagemagick:
convert min-is-black.tiff min-is-black.pbm
convert min-is-white.tiff min-is-white.pbm
Now you'll notice that the pbm files look identical to the tiff files from
which they were converted.

Actual Results:

Convered above: tifftopnm ignore photometric interpretation

Expected Results:

tifftopnm should honor photometric interpretation

Additional Information:
You will find that other viewers than ee including xview, gqview, gimp,
etc. all honor photometric interpretation.  However, lots of Windows
viewers don't.  None the less, it is most definitely a bug to ignore
photometric interpretation, and it is a bug that has been introduced
relatively recently in pbm's life.  Very odd given that it links against
libtiff as do most of these other tools.

Using tiffcp to create uncompressed tiffs doesn't affect this, so the
problem is unrelated to the fact that the tiffs use g4 compression.

If I have time I may try to fix this and submit a patch.  I'm guessing it's
going to be a simple fix.

I am now attaching the two tiff files.  They are very small.
Comment 1 Jay Berkenbilt 2001-08-23 18:07:44 EDT
Created attachment 29294 [details]
tiff file with min-is-white photometric interpretation
Comment 2 Jay Berkenbilt 2001-08-23 18:08:20 EDT
Created attachment 29295 [details]
tiff file with min-is-black photometric interpretation
Comment 3 Jay Berkenbilt 2001-08-23 18:32:31 EDT
Created attachment 29296 [details]
patch to fix this problem
Comment 4 Jay Berkenbilt 2001-08-23 18:34:45 EDT
I was right.  It was simple.  I've attached the patch as a file, but I'm
including it here as well.  I quick glance through the code will indicate that
the line of code I deleted wasn't doing anything.

Usually when I find something like this, I report it to the "upstream"
maintainers as well, but in this case, I don't know what to do because so many
patches are applied.

My patch is relative to RedHat's version; i.e., after rpm -bp netpbm.spec.
Comment 5 Jay Berkenbilt 2001-08-23 18:35:13 EDT
--- pnm/tifftopnm.c.qdist       Thu Aug 23 18:29:32 2001
+++ pnm/tifftopnm.c     Thu Aug 23 18:40:07 2001
@@ -501,8 +501,7 @@
             for ( col = 0; col < cols; ++col ) {
-                sample = maxval - sample;
-                PNM_ASSIGN1( xelrow[col], samplebuf[col] );
+                PNM_ASSIGN1( xelrow[col], maxval - samplebuf[col] );
                 alpharow[col] = 0;
Comment 6 Phil Knirsch 2001-11-07 09:44:01 EST
Fixed in the latest version, available via rawhide soon.

Version: netpbm-9.20-1
Read ya, Phil

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