#13015: Correct the behavior of loading tiff resolution

1 view
Skip to first unread message

wxTrac

unread,
Mar 4, 2011, 10:39:40 PM3/4/11
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/13015>

#13015: Correct the behavior of loading tiff resolution
---------------------------+------------------------------------------------
Reporter: scottb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.2
Component: GUI-all | Version: 2.9.1
Keywords: wxTIFFHandler | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------
wxTIFFHandler::LoadFile ignores resolution data when RESOLUTIONUNITS are
not set in the tiff file. The tiff RESOLUTIONUNITS tag has a default value
which tiff readers are supposed to assume in the event that the tag is not
set.

This patch corrects this. Also, according to the tiff spec, even if
RESOLUTIONUNITS is set to none, the resolution info (x and y) is still
valid. This is also corrected.

The other change in this patch is to preserve three digits of decimal
precision when storing the float x and y resolution, instead of rounding
to int. This helps to avoid significant errors in the case of Dots Per
Centimeter.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/13015>

wxTrac

unread,
Mar 5, 2011, 8:26:29 PM3/5/11
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:1>

#13015: Correct the behavior of loading tiff resolution
---------------------------+------------------------------------------------
Reporter: scottb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.2
Component: GUI-all | Version: 2.9.1
Keywords: wxTIFFHandler | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------

Comment(by scottb):

I just updated the patch to use the tiff spec defaults provided by libtiff
instead of my own reading of the tiff spec.

I also added reading bits per sample, samples per pixel and compression
(all with the correct defaults) so that reading a tiff with wxWidgets and
then writing it back to a file will yield a similar file instead of a
potentially very different file (such as a one bit group 4 file ending up
un-compressed 24 bit when re-written). Also without this, there is no way
for an app to know if it has a monochrome or color image (this is why I
need it).

I just ran a test to verify the results.

Original image: 30 x 42 inches, 200 dpi 1 bit per sample, 1 sample per
pixel

Original file: 1 bit, PackBits Compression .68 MB
Re-Written with patch: original settings preserved .69 MB
Re-Written with bps and spp but no compression set 6.3 MB (one
bit uncompressed)
Re-Written without patch (no bps, spp or compression) 147.7 MB (24 bit
uncompressed)

With patch but setting compression to COMPRESSION_CCITTFAX4 (4) .23 MB


(suggestion for different patch: in SaveFile we should default to a
lossless compression in the case of one bit image with no compression
specified - such as 3 or 4. Also SaveFile should have a
GetOptionInt(wxIMAGE_OPTION_QUALITY) to pass on jpeg quality so if the app
is specifying a lossy compression, they can control it: TIFFSetField (
tif, TIFFTAG_JPEGQUALITY, qual );

I'm not saving any color tiffs so I haven't written this patch. (Does
anybody want a class to save wxImages to a pdf?) Sorry for the detour.)


--
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:1>

wxTrac

unread,
Mar 6, 2011, 2:04:52 PM3/6/11
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:2>

#13015: Correct the behavior of loading tiff resolution
---------------------------+------------------------------------------------

Reporter: scottb | Owner: disc
Type: enhancement | Status: accepted


Priority: normal | Milestone: 2.9.2
Component: GUI-all | Version: 2.9.1
Keywords: wxTIFFHandler | Blockedby:
Patch: 1 | Blocking:
---------------------------+------------------------------------------------

Changes (by disc):

* owner: => disc
* status: new => accepted

--
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:2>

wxTrac

unread,
Mar 20, 2011, 3:48:04 PM3/20/11
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:3>

#13015: Correct the behavior of loading tiff resolution

--------------------------+-------------------------------------------------
Reporter: scottb | Owner: disc
Type: enhancement | Status: closed

Priority: normal | Milestone: 2.9.2
Component: GUI-all | Version: 2.9.1

Resolution: fixed | Keywords: wxTIFFHandler
Blockedby: | Patch: 1
Blocking: |
--------------------------+-------------------------------------------------
Changes (by DS):

* status: accepted => closed
* resolution: => fixed


Comment:

(In [67264]) Made some TIFF reading adjustments.

Read a few TIFF tags that assist with having a similar TIFF file when
saving the image again, instead of (by default) always saving as a 24-bit
RGB image. Also, in accordance with libtiff, allow reading X and Y
resolution values even if the resolution unit tag is not set.

Applied (modified) patch by scottb. Closes #13015.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/13015#comment:3>

Reply all
Reply to author
Forward
0 new messages