exiftool / exiftool

ExifTool meta information reader/writer
https://exiftool.org/
GNU General Public License v3.0
3.29k stars 329 forks source link

Cannot transfer all exif from GeoTIFF to a COG (cloud optimised Geotiff) #292

Closed luipir closed 3 days ago

luipir commented 3 days ago

Describe the bug cannot transfer all Exif from a Geotiff to it's COG version

To Reproduce Steps to reproduce the behavior:

1) get a generic GeoTIFF 2) convert in COG "format" generated with: gdal_translate source.tif destination.tif -of GTiff -co COMPRESS=DEFLATE -co TILED=YES or with: rio cogeo create source.tif destination.tif 3) transfer tags from source to destination with: exiftool -tagsfromfile sopurce.tif -GeoTiffDirectory -GeoTiffDoubleParams -GeoTiffAsciiParams destination.tif 4) verify that not all tags are transferred from source to destination

Expected behavior

Desktop (please complete the following information): Ubuntu 24.04.1 LTS 0.27.6 (installed via apt)

boardhead commented 3 days ago

I don't know what a COG format is. Could you upload some sample files? (generic GeoTIFF and the converted COG file)

luipir commented 3 days ago

Hi @boardhead a COG is a normal GeoTiff reorganised to optimise HTTP get of portion of image or metadata. in this way the image can be served via HTTP without to download all the image and servig only the visible part. It is documente here: https://guide.cloudnativegeo.org/cloud-optimized-geotiffs/intro.html#:~:text=Cloud%2DOptimized%20GeoTIFF%20(COG),for%20display%20or%20data%20reading.

You can get any geotiff e.g. from https://github.com/mommermi/geotiff_sample and convert to COG as in stap 2) e.g. you need to install GDAL or rio-cogeo. I would suggest GDAL.

luipir commented 3 days ago

hi @boardhead Here two test images, the same one is GeoTiff and the other COG transformed. NOTE the images are really small and not clear to me if the issue depend also on size of the image. I would use these test data but also a relatively big image to be sure to point correctly into tag directaories samples.zip

boardhead commented 3 days ago

WIth these samples, template_cog.tif contains geotiff metadata and template_nocog.tif doesn't. I am able to copy the geotiff from one to the other.

% exiftool -geotiff:all .
======== ./template_cog.tif
Geo Tiff Version                : 1.1.0
GT Model Type                   : Projected
GT Raster Type                  : Pixel Is Area
GT Citation                     : WGS 84 / UTM zone 33N
Geog Citation                   : WGS 84
Geog Angular Units              : Angular Degree
Projected CS Type               : WGS84 UTM zone 33N
Proj Linear Units               : Linear Meter
======== ./template_nocog.tif
    1 directories scanned
    2 image files read
% exiftool -tagsfromfile template_cog.tif -GeoTiffDirectory -GeoTiffDoubleParams -GeoTiffAsciiParams template_nocog.tif 
    1 image files updated
% exiftool -geotiff:all .
======== ./template_cog.tif
Geo Tiff Version                : 1.1.0
GT Model Type                   : Projected
GT Raster Type                  : Pixel Is Area
GT Citation                     : WGS 84 / UTM zone 33N
Geog Citation                   : WGS 84
Geog Angular Units              : Angular Degree
Projected CS Type               : WGS84 UTM zone 33N
Proj Linear Units               : Linear Meter
======== ./template_nocog.tif
Geo Tiff Version                : 1.1.0
GT Model Type                   : Projected
GT Raster Type                  : Pixel Is Area
GT Citation                     : WGS 84 / UTM zone 33N
Geog Citation                   : WGS 84
Geog Angular Units              : Angular Degree
Projected CS Type               : WGS84 UTM zone 33N
Proj Linear Units               : Linear Meter
    1 directories scanned
    2 image files read
luipir commented 3 days ago

let me give you a working case hopefully without to share a big image

luipir commented 3 days ago

hmmm... seems that -tagsfromfile works also for most of the tags, I've only an issue when a tag is duplicated

e.g. if I've two repeated tags e.g. Exif.Image.Software val1 Exif.Image.Software val2 Xmp.tiff.Software val1

for some reason (Sorry I'm not an exif or tag expert), after transfer, remain only:

Exif.Image.Software val2 Xmp.tiff.Software val2

e.g. the latest value and xmp updated with the latest value

boardhead commented 3 days ago

There shouldn't be 2 EXIF:Software tags in the same location. Use this command to see the locations:

exiftool -a -G1 -s FILE

If they are in different locations, you can copy them both with -all:software, or by specifying both with their specific locations.

luipir commented 3 days ago

@boardhead with only -tagsfromfile thi sis the result:

Source

[IFD0]          Software                        : v6.4.0
[XMP-tiff]      Software                        : v6.4.0
[IFD1]          Software                        : UltraMap v6.4.0.1 (Build 44.1.2408.901)
[IFD2]          Software                        : UltraMap v6.4.0.1 (Build 44.1.2408.901)
[IFD3]          Software                        : UltraMap v6.4.0.1 (Build 44.1.2408.901)

_____________________
Destination

[IFD0]          Software                        : UltraMap v6.4.0.1 (Build 44.1.2408.901)
[XMP-tiff]      Software                        : UltraMap v6.4.0.1 (Build 44.1.2408.901)

adding -all:Software give me

18:30 $ exiftool -all:Software -tagsfromfile yestag_temporary.tif yestag_cog.tif
Ignored superfluous tag name or invalid option: -all:Software
    1 image files updated
boardhead commented 3 days ago

The -all:software must come after the -tagsfromfile option

boardhead commented 3 days ago

But I would recommend this:

exiftool -tagsfromfile yestag_temporary.tif -all:all yestag_cog.tif

To copy everything to the corresponding location.

luipir commented 3 days ago

tnx @boardhead it works :), now trying to find the way to do this via python api (if any)