Author Topic: Copying GEOTIFF tags  (Read 10080 times)

yvecai

  • Newbie
  • *
  • Posts: 2
Copying GEOTIFF tags
« on: June 13, 2010, 12:09:59 PM »
I am modifying GeoTIFF images with ImageMagick, which does not keep all tags from the original image.
Then I would like to copy all the tags from original image to the one created by ImageMagick. Maybe this is not so simple because it doesn't work with -tagsfromfiles old.tiff -ALL:ALL new.tiff.

Here is a tag set from the orginal image:
yves@maisonuxII:~/mapnik/SRTM/data/TIF$ exiftool -G -D hillshade.tif
Code: [Select]
[ExifTool]          - ExifTool Version Number         : 7.89
[File]              - File Name                       : hillshade.tif
[File]              - Directory                       : .
[File]              - File Size                       : 281 MB
[File]              - File Modification Date/Time     : 2010:05:13 10:43:09+02:00
[File]              - File Type                       : TIFF
[File]              - MIME Type                       : image/tiff
[File]              - Exif Byte Order                 : Little-endian (Intel, II)
[EXIF]            256 Image Width                     : 18554
[EXIF]            257 Image Height                    : 15887
[EXIF]            258 Bits Per Sample                 : 8
[EXIF]            259 Compression                     : Uncompressed
[EXIF]            262 Photometric Interpretation      : BlackIsZero
[EXIF]            273 Strip Offsets                   : (Binary data 152905 bytes, use -b option to extract)
[EXIF]            277 Samples Per Pixel               : 1
[EXIF]            278 Rows Per Strip                  : 1
[EXIF]            279 Strip Byte Counts               : (Binary data 95321 bytes, use -b option to extract)
[EXIF]            284 Planar Configuration            : Chunky
[EXIF]            339 Sample Format                   : Unsigned integer
[EXIF]          33550 Pixel Scale                     : 30 30 0
[EXIF]          33922 Model Tie Point                 : 0 0 0 333958.472379821 5942074.07243111 0
[EXIF]          42113 GDAL No Data                    : 0
[GeoTiff]           1 Geo Tiff Version                : 1.1.0
[GeoTiff]        1024 GT Model Type                   : Projected
[GeoTiff]        1025 GT Raster Type                  : Pixel Is Area
[GeoTiff]        1026 GT Citation                     : unnamed
[GeoTiff]        2048 Geographic Type                 : User Defined
[GeoTiff]        2049 Geog Citation                   : unnamed ellipse
[GeoTiff]        2050 Geog Geodetic Datum             : User Defined
[GeoTiff]        2054 Geog Angular Units              : Angular Degree
[GeoTiff]        2056 Geog Ellipsoid                  : User Defined
[GeoTiff]        2057 Geog Semi Major Axis            : 6378137
[GeoTiff]        2058 Geog Semi Minor Axis            : 6378137
[GeoTiff]        3072 Projected CS Type               : User Defined
[GeoTiff]        3074 Projection                      : User Defined
[GeoTiff]        3075 Proj Coord Trans                : Mercator
[GeoTiff]        3076 Proj Linear Units               : Linear Meter
[GeoTiff]        3080 Proj Nat Origin Long            : 0
[GeoTiff]        3081 Proj Nat Origin Lat             : 0
[GeoTiff]        3082 Proj False Easting              : 0
[GeoTiff]        3083 Proj False Northing             : 0
[GeoTiff]        3092 Proj Scale At Nat Origin        : 1
[Composite]         - Image Size                      : 18554x15887

And here from image created by IM:

Code: [Select]
[ExifTool]          - ExifTool Version Number         : 7.89
[File]              - File Name                       : hillshade_NBC.tif
[File]              - Directory                       : .
[File]              - File Size                       : 281 MB
[File]              - File Modification Date/Time     : 2010:06:13 18:02:47+02:00
[File]              - File Type                       : TIFF
[File]              - MIME Type                       : image/tiff
[File]              - Exif Byte Order                 : Little-endian (Intel, II)
[EXIF]            256 Image Width                     : 18554
[EXIF]            257 Image Height                    : 15887
[EXIF]            258 Bits Per Sample                 : 8
[EXIF]            259 Compression                     : Uncompressed
[EXIF]            262 Photometric Interpretation      : BlackIsZero
[EXIF]            266 Fill Order                      : Normal
[EXIF]            269 Document Name                   : hillshade_NBC.tif
[EXIF]            273 Strip Offsets                   : (Binary data 152876 bytes, use -b option to extract)
[EXIF]            274 Orientation                     : Horizontal (normal)
[EXIF]            277 Samples Per Pixel               : 1
[EXIF]            278 Rows Per Strip                  : 1
[EXIF]            279 Strip Byte Counts               : (Binary data 95321 bytes, use -b option to extract)
[EXIF]            282 X Resolution                    : 72
[EXIF]            283 Y Resolution                    : 72
[EXIF]            284 Planar Configuration            : Chunky
[EXIF]            296 Resolution Unit                 : inches
[EXIF]            297 Page Number                     : 0 1
[EXIF]            305 Software                        : ImageMagick 6.5.7-8 2009-11-26 Q16 http://www.imagemagick.org
[Composite]         - Image Size                      : 18554x15887

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: Copying GEOTIFF tags
« Reply #1 on: June 13, 2010, 03:38:04 PM »
Sorry, ExifTool does not yet have the ability to write GeoTiff tags.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yvecai

  • Newbie
  • *
  • Posts: 2
Re: Copying GEOTIFF tags
« Reply #2 on: June 13, 2010, 05:56:50 PM »
That's a fast and precise answer, thanks !

Looking a little more deeply how GeoTiffs are made to see how I could do, I've found geotifcp:
http://www.remotesensing.org/geotiff/geotifcp.html
Works perfectly.

All info on geotiff can be found here: http://trac.osgeo.org/geotiff/

mmx64

  • Newbie
  • *
  • Posts: 5
Re: Copying GEOTIFF tags
« Reply #3 on: September 07, 2010, 07:16:06 AM »
Sorry, ExifTool does not yet have the ability to write GeoTiff tags.

Can I ask you what your plans are regarding writing/deleting GeoTiff tags?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: Copying GEOTIFF tags
« Reply #4 on: September 07, 2010, 07:23:23 AM »
I've had no requests yet to add this ability, so I haven't got any plans at this point.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mmx64

  • Newbie
  • *
  • Posts: 5
Re: Copying GEOTIFF tags
« Reply #5 on: September 07, 2010, 07:54:30 AM »
Well, conside this a humble request then ;) Especially removing the tag (for privacy issues).

Great program btw! Keep up the good work!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: Copying GEOTIFF tags
« Reply #6 on: September 07, 2010, 07:59:33 AM »
OK.  I'll put this on the list.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: Copying GEOTIFF tags
« Reply #7 on: September 07, 2010, 08:10:39 AM »
I just took a quick look at this.  Now I remember why this ability wasn't added:

The GeoTIFF specification sucks.  Why can't people ever design a specification that is compatible with existing standards?  The unfortunate structure of the design means that it can't be processed in a single pass.  There is already special logic needed in ExifTool to cache the necessary GeoTIFF information in memory until it can be decoded, and writing it will be even more complicated. :(

But I will see what I can do.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mmx64

  • Newbie
  • *
  • Posts: 5
Re: Copying GEOTIFF tags
« Reply #8 on: September 07, 2010, 08:56:23 AM »
Well that sure sounds like it sucks :(
Anything you can do would be appreciated. Good luck!

caller82

  • Newbie
  • *
  • Posts: 1
Re: Copying GEOTIFF tags
« Reply #9 on: February 06, 2014, 05:22:53 AM »
hi,

has this feature been integrated so far? I am searching for a cross plattform solution to restore geotiff meta data after image magic removed it. geotifcp works fine, but only on linux. its hard to find a distributeable solution for windows, and even harder on mac :-(

please let me know if you have any alternative suggestions for me!

THX
-marco

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14879
    • ExifTool Home Page
Re: Copying GEOTIFF tags
« Reply #10 on: February 06, 2014, 07:36:38 AM »
Hi Marco,

I should have realized this before, a simple copy of existing GeoTiff tags may be done by creating user-defined tags with the following config file:

Code: [Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0x87af => {
            Name => 'GeoTiffDirectoryBlock',
            Format => 'undef',
            Writable => 'undef',
            Binary => 1,
        },
        0x87b0 => {
            Name => 'GeoTiffDoubleBlock',
            Format => 'undef',
            Writable => 'undef',
            Binary => 1,
        },
        0x87b1 => {
            Name => 'GeoTiffAsciiBlock',
            Writable => 'string',
            Binary => 1,
        },
    },
);

(see the sample config file for instructions on using a config file.)

The command is then:

exiftool -tagsfromfile src.tiff "-geotiff*" dst.tiff

This should work as long as the source and destination TIFF images have the same byte ordering.

- Phil

Edit:  I will build this ability into ExifTool 9.50, which will also properly handle the byte ordering.
« Last Edit: February 06, 2014, 10:21:51 AM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).