IM: does not recognize some GeoTIFF fields

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
MrRedwood

IM: does not recognize some GeoTIFF fields

Post by MrRedwood »

I was requested here to post a question that I'd placed in the Users forum. Although I'm satisfied with my results, it seems to be the case that there are some tags and/or fields in TIFF images, probably associated with GeoTIFF, that IM doesn't understand.

The post in its original format is here.

I'd be happy to respond with any details I can provide, but I'm no expert in GeoTIFF or anything else relevant to this forum.
--
Richard
MrRedwood wrote:This problem has been reported in two previous posts (here and here), but was not apparently resolved.

I'm trying to convert some TIFFs containing USGS Topographic maps, each of which is pretty big. There are a lot that I want to convert -- hundreds -- and each takes quite a while on my old Mac, so I was hoping to test which of the tools I have available would be quickest (my default assumption is that the command-line tools would be quicker, thus my interest in ImageMagick).

I'd appreciate any advice on whether there is a fix, or a workaround (e.g., build from source) or other similar conversion tools? Thanks.

(FYI FWIW, all of the topo maps covering California are available online; the one I'm experimenting with is "o37121e6", covering "MENDENHALL SPRINGS" in southeast Alameda County, and is online here.)

The error I get is:
$ convert -verbose o37121e6.tif o37121e6.png
convert: Not a TIFF file, bad version number 10752 (0x2a00). `o37121e6.tif'.
convert: missing an image filename `o37121e6.png'.


The descriptions of the file are:
$ file o37121e6.tif
o37121e6.tif: TIFF image data, little-endian


Mac's Preview.app gives more:
File Name: o37121e6.tif
Document Type: TIFF Document
File Side: 15736817 bytes
Color Model: RGB
Depth: 8
Is Indexed: 1
Orientation: 1
Pixel Height: 10637
Pixel Width: 7927

TIFF Properties
Compression: 32773
Orientation: 1
Photometric Interpretation: 3
Resolution Unit: 1
Software: IMAGINE TIFF Support Copyright 1991-1999 by ERDAS, Inc.
X Resolution: 0.653
Y Resolution: 0.653


GraphicConverter adds a little more:
Size: 7929x10637 pixel (84.3 Megapixel)
File Format: TIFF (P), Little-Endian, Packbits compression/Striped(5319), GEO
File Length: 15.0MB
Compression 1:5


This is with a Mac running 10.4.11, and recently-downloaded binary version of ImageMagick:
Version: ImageMagick 6.4.0 04/28/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC


--
Richard
fmw42 wrote:From my experience, when I first started using IM on my Mac OSX Tiger PPC and downloaded and installed the binary, I was never able to either read a TIFF created by Photoshop, GraphicConvert, Debabelizer, etc nor could I create one in IM and have it display in any of these applications including Preview.

When I started building IM from source and building the libTiff delegate myself, I was then able to display most Tiffs within IM and create ones that could be read by these other apps.

I have not used any recent IM binary in quite some time, so I cannot say that this continues.

I am not sure IM can handle GEOTIFFs, if that is what you have, but have no experience with such. I have found that IM cannot display some TIFFs from ImageJ.

Also note that IM is going through some enhancements to support parallel processing. See http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=11173

________________________

I am on IM 6.4.1-3 Q16 HDRI on a Mac OSX Tiger PPC.

I downloaded your image and got its verbose info, but with some error messages:

convert o37121e6.tif -verbose info:
Image: o37121e6.tif
Format: TIFF (Tagged Image File Format)
Class: PseudoClass
Geometry: 7927x10637+0+0
Resolution: 0.653x0.653
Print size: 12139.4x16289.4
Units: Undefined
Type: Palette
Base type: Palette
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
Channel statistics:
red:
min: 0.5 (7.62951e-06)
max: 65280.5 (0.996117)
mean: 57911.4 (0.883671)
standard deviation: 11452.7 (0.174758)
green:
min: 0.5 (7.62951e-06)
max: 65280.5 (0.996117)
mean: 60297.3 (0.920078)
standard deviation: 13767 (0.210071)
blue:
min: 0.5 (7.62951e-06)
max: 65280.5 (0.996117)
mean: 52882.8 (0.806939)
standard deviation: 14939.8 (0.227967)
Histogram:
42069141: (65281,65281,65281) #FF01FF01FF01 rgb(99.6117%,99.6117%,99.6117%)
30358357: (53761,65281,45313) #D201FF01B101 rgb(82.0333%,99.6117%,69.1424%)
6049736: (56833,42753,37377) #DE01A7019201 rgb(86.7208%,65.2361%,57.0329%)
2144904: ( 1, 1, 1) #000100010001 rgb(0.000762951%,0.000762951%,0.000762951%)
2051595: (41473,24577,18177) #A20160014701 rgb(63.283%,37.5013%,27.7356%)
836036: (50433,25857,50433) #C5016501C501 rgb(76.9551%,39.4545%,76.9551%)
372223: (23297,40705,58881) #5B019F01E601 rgb(35.5482%,62.1111%,89.8459%)
323204: (58881,11521, 7681) #E6012D011E01 rgb(89.8459%,17.5792%,11.7197%)
114213: (51713,57601,62721) #CA01E101F501 rgb(78.9082%,87.8927%,95.7053%)
90: (65281,51713,50433) #FF01CA01C501 rgb(99.6117%,78.9082%,76.9551%)
Colormap: 256
0: (65281,65281,65281) #FF01FF01FF01 rgb(99.6117%,99.6117%,99.6117%)
[Colormap details elided -- see original post for complete information.]
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Page geometry: 7927x10637+0+0
Dispose: Undefined
Iterations: 0
Compression: RLE
Orientation: TopLeft
Properties:
create-date: 2008-05-23T19:36:44-07:00
modify-date: 2006-01-17T18:57:08-08:00
signature: b1d0147f36b3ca70d1e717e77d90910cf5479abcf8eab2ae7899829f7d627bc4
tiff:rows-per-strip: 2
tiff:software: IMAGINE TIFF Support
Copyright 1991 - 1999 by ERDAS, Inc. All Rights Reserved
@(#)$RCSfile: etif.c $ $Revision: 1.9.1.2 $ $Date: 2001/12/05 00:33:12Z $
Artifacts:
verbose: true
Tainted: False
Filesize: 0b
Number pixels: 80.4133mb
Pixels per second: 1016.58kb
User time: 17.930u
Elapsed time: 1:22
Version: ImageMagick 6.4.1 05/19/08 Q16 HDRI http://www.imagemagick.org
convert: o37121e6.tif: unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'.



So I tried:

convert o37121e6.tif[100x100+0+0] tmp.png
convert: o37121e6.tif: unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'.


I would recommend that you repost this to the bugs forum at http://www.imagemagick.org/discourse-server/viewforum.php?f=3 or the developers forum if this is a new TIFF format that IM does not know about at http://www.imagemagick.org/discourse-server/viewforum.php?f=2

And if possible post a link to any documentation on this particular TIFF format.

If these images are truly GEOTIFF, then the format specification can be found at http://www.remotesensing.org/geotiff/spec/contents.html

P.S. I for one would like to see IM be able to handle GEOTIFF format data as it opens the door to a wide range of satellite imagery, map and terrain elevation data (http://casil.ucdavis.edu/casil/doc/data.html)
MrRedwood wrote:Excellent. I'm reluctant these days to install sources, since I haven't coded in about twenty years and my hobbies now lean in other directions; last time I tried installing a port (GRAMPS) it took forever due to the number of dependencies and then still didn't work :-( But apparently all those other ports still lying around on my machine helped somewhat: all of Imagemagick's dependencies were still here, so it installed and ran the first time! Glory be! (While perusing IM's help files, I discovered the heretofore unsuspected existence of OptiPNG, installed it too, and discovered it doesn't like the compression already applied to these TIFs.)

And when I ran the convert installed from sources, I got the same results as you. I couldn't tell from your post whether the programs had actually successfully created a new PNG, and was pleased to discover they do: in my one test so far, the resulting PNG is only 45.2% of the size of the TIF, and a cursory visual inspection shows no degradation.

So, thank you!

PS, re GeoTIFF, the verbose conversion in my case also provide this, after much other info your info: had provided:
Tag 34737: IMAGINE GeoTIFF Support
Copyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved
@(#)$RCSfile: egtf.c $ $Revision: 1.9.2.4 $ $Date: 2002/01/24 16:43:13Z $
Projection = Albers Conical Equal Area|IMAGINE GeoTIFF Support
Copyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved
@(#)$RCSfile: egtf.c $ $Revision: 1.9.2.4 $ $Date: 2002/01/24 16:43:13Z $
Projection Name = Custom
Units = meters
GeoTIFF Units = meters|
o37121e6.tif TIFF 7927x10637 7927x10637+0+0 PseudoClass 256c 8-bit 15.0078mb 18.070u 2:08
o37121e6.tif=>o37121e6.png TIFF 7927x10637 7927x10637+0+0 PseudoClass 256c 8-bit 6.78301mb 39.160u 2:04
convert: o37121e6.tif: unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'.
convert: o37121e6.tif: unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'.
fmw42 wrote:Please repost all of this to Developers forum as it looks like there are new fields in the GEOTIFF that IM does not understand. I suspect they will be willing to add these fields. Post the link to the GEOTIFF docs so they can find all the missing fields. It will help others in the future if we can get IM to make the upgrades.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: IM: does not recognize some GeoTIFF fields

Post by magick »

The TIFF specification permits proprietary tags and simply ignores them. At some point we could enhance ImageMagick to understand the proprietary GEOTiff tags but this enhancment is not currently on our radar.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: IM: does not recognize some GeoTIFF fields

Post by anthony »

of course as IM is open source, and you have the drive to wnat this. You could look at adding it yourself and contributing patches.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply