convert doesn't like some EXIF tags

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
wumpus
Posts: 11
Joined: 2016-04-29T17:02:11-07:00
Authentication code: 1151

convert doesn't like some EXIF tags

Post by wumpus »

Why would convert care? It's complaining about some (newer) EXIF tags: OffsetTime, OffsetTimeOriginal and OffsetTimeDigitized. It complains and strips them out when converting from TIFF to JPEG.

Code: Select all

C:\TEMP\test>convert -quality 95 IMG_20170911_0002.tif IMG_20170911_0002.jpg
convert: Unknown field with tag 36880 (0x9010) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/925.
convert: Unknown field with tag 36881 (0x9011) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/925.
convert: Unknown field with tag 36882 (0x9012) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/925.

C:\TEMP\test>convert --version
Version: ImageMagick 7.0.6-0 Q16 x64 2017-06-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
My env:
Win10 x64 Pro
Canon 9000F Mark II
TIFF image files
ImageMagick 7.0.6-0 Q16
ExifTool v10.61
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert doesn't like some EXIF tags

Post by fmw42 »

It is only a warning to let you know there are unknown tags. To suppress warnings when using tiff images, add -quiet right after convert.

Also proper IM syntax is to read the input before any settings or operators. IM 6 is forgiving, but not IM 7
wumpus
Posts: 11
Joined: 2016-04-29T17:02:11-07:00
Authentication code: 1151

Re: convert doesn't like some EXIF tags

Post by wumpus »

Like this?

Code: Select all

C:\TEMP\test>convert -quiet IMG_20170911_0001.tif -quality 95 IMG_20170911_0001.jpg

C:\TEMP\test>
But it still doesn't write the (unknown?) tags to the resultant JPEG file it created.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert doesn't like some EXIF tags

Post by fmw42 »

No it won't since IM does not recognize those tags. All -quiet does is to prevent the warnings from showing. I thought that was your issue.

You could ask on the Developer's forum to include those tags as an enhancement.
wumpus
Posts: 11
Joined: 2016-04-29T17:02:11-07:00
Authentication code: 1151

Re: convert doesn't like some EXIF tags

Post by wumpus »

It seems the tag omission during the conversion has nothing to do with the unknown tags. If I don't put the unknown tags in the file, convert still is not copying over some EXIF tags, namely:
  • DateTime (ModifyDate to exiftool)
  • DateTimeDigitized (CreateDate to exiftool)
  • DateTimeOriginal
I have a sample image IMG_20170912_0001.tif created by my Canon 9000F Mark II scanner and it's Canon IJ Scan Utility. ExifTool shows it contains the following tags:

Code: Select all

C:\TEMP\test>exiftool -v IMG_20170912_0001.tif
  ExifToolVersion = 10.61
  FileName = IMG_20170912_0001.tif
  Directory = .
  FileSize = 5303788
  FileModifyDate = 1505192941.45003
  FileAccessDate = 1505192958.3514
  FileCreateDate = 1505192958.3514
  FilePermissions = 33206
  FileType = TIFF
  FileTypeExtension = TIF
  MIMEType = image/tiff
  ExifByteOrder = II
  + [IFD0 directory with 14 entries]
  | 0)  SubfileType = 0
  | 1)  ImageWidth = 1788
  | 2)  ImageHeight = 988
  | 3)  BitsPerSample = 8 8 8
  | 4)  Compression = 1
  | 5)  PhotometricInterpretation = 2
  | 6)  StripOffsets = 8 10736 21464 32192 42920 53648 64376 75104 85832 96560 107288 1[snip]
  | 7)  SamplesPerPixel = 3
  | 8)  RowsPerStrip = 2
  | 9)  StripByteCounts = 10728 10728 10728 10728 10728 10728 10728 10728 10728 10728 1[snip]
  | 10) XResolution = 300 (300000/1000)
  | 11) YResolution = 300 (300000/1000)
  | 12) PlanarConfiguration = 1
  | 13) ResolutionUnit = 2
If I convert it using ImageMagick:

Code: Select all

C:\TEMP\test>convert -version
Version: ImageMagick 7.0.6-0 Q16 x64 2017-06-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

C:\TEMP\test>convert IMG_20170912_0001.tif -quality 95 IMG_20170912_0001.jpg
ExifTool shows the converted JPEG file contains the following tags:

Code: Select all

C:\TEMP\test>exiftool -v IMG_20170912_0001.jpg
  ExifToolVersion = 10.61
  FileName = IMG_20170912_0001.jpg
  Directory = .
  FileSize = 1166897
  FileModifyDate = 1505193588.30088
  FileAccessDate = 1505193588.23837
  FileCreateDate = 1505193468.87307
  FilePermissions = 33206
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | ResolutionUnit = 1
  | XResolution = 300
  | YResolution = 300
  | ThumbnailWidth = 0
  | ThumbnailHeight = 0
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0 (15 bytes):
  ImageWidth = 1788
  ImageHeight = 988
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
JPEG DHT (28 bytes):
JPEG DHT (85 bytes):
JPEG DHT (27 bytes):
JPEG DHT (93 bytes):
JPEG SOS
Now if I copy the original TIFF file and use ExifTool to add the DateTime, DateTimeDigitized and DateTimeOriginal tags:

Code: Select all

C:\TEMP\test>copy IMG_20170912_0001.tif IMG_20170912_0002.tif
        1 file(s) copied.

C:\TEMP\test>exiftool -exif:DateTimeOriginal="20170912 00:00:00" -exif:CreateDate="20170912 00:00:00" -exif:ModifyDate="20170912 00:00:00" IMG_20170912_0002.tif
    1 image files updated
ExifTool shows the new TIFF to have the following tags (which include the newly added tags):

Code: Select all

C:\TEMP\test>exiftool -v IMG_20170912_0002.tif
  ExifToolVersion = 10.61
  FileName = IMG_20170912_0002.tif
  Directory = .
  FileSize = 5303950
  FileModifyDate = 1505193366.22399
  FileAccessDate = 1505193366.20836
  FileCreateDate = 1505193007.81244
  FilePermissions = 33206
  FileType = TIFF
  FileTypeExtension = TIF
  MIMEType = image/tiff
  ExifByteOrder = II
  + [IFD0 directory with 16 entries]
  | 0)  SubfileType = 0
  | 1)  ImageWidth = 1788
  | 2)  ImageHeight = 988
  | 3)  BitsPerSample = 8 8 8
  | 4)  Compression = 1
  | 5)  PhotometricInterpretation = 2
  | 6)  StripOffsets = 4318 15046 25774 36502 47230 57958 68686 79414 90142 100870 1115[snip]
  | 7)  SamplesPerPixel = 3
  | 8)  RowsPerStrip = 2
  | 9)  StripByteCounts = 10728 10728 10728 10728 10728 10728 10728 10728 10728 10728 1[snip]
  | 10) XResolution = 300 (300000/1000)
  | 11) YResolution = 300 (300000/1000)
  | 12) PlanarConfiguration = 1
  | 13) ResolutionUnit = 2
  | 14) ModifyDate = 2017:09:12 00:00:00
  | 15) ExifOffset (SubDirectory) -->
  | + [ExifIFD directory with 6 entries]
  | | 0)  ExifVersion = 0231
  | | 1)  DateTimeOriginal = 2017:09:12 00:00:00
  | | 2)  CreateDate = 2017:09:12 00:00:00
  | | 3)  ComponentsConfiguration = 1 2 3 0
  | | 4)  FlashpixVersion = 0100
  | | 5)  ColorSpace = 65535
If I now convert that new TIFF to JPEG using ImageMagick and look at the tags in that JPEG file, the new tags in the TIFF file aren't the resultant JPEG file:

Code: Select all

C:\TEMP\test>convert IMG_20170912_0002.tif -quality 95 IMG_20170912_0002.jpg

C:\TEMP\test>exiftool -v IMG_20170912_0002.jpg
  ExifToolVersion = 10.61
  FileName = IMG_20170912_0002.jpg
  Directory = .
  FileSize = 1166897
  FileModifyDate = 1505193772.48408
  FileAccessDate = 1505193772.4216
  FileCreateDate = 1505193772.4216
  FilePermissions = 33206
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | ResolutionUnit = 1
  | XResolution = 300
  | YResolution = 300
  | ThumbnailWidth = 0
  | ThumbnailHeight = 0
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0 (15 bytes):
  ImageWidth = 1788
  ImageHeight = 988
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
JPEG DHT (28 bytes):
JPEG DHT (85 bytes):
JPEG DHT (27 bytes):
JPEG DHT (93 bytes):
JPEG SOS
But I can add them back to the new JPEG file using ExifTool again:

Code: Select all

C:\TEMP\test>exiftool -exif:DateTimeOriginal="20170912 00:00:00" -exif:CreateDate="20170912 00:00:00" -exif:ModifyDate="20170912 00:00:00" IMG_20170912_0002.jpg
    1 image files updated

C:\TEMP\test>exiftool -v IMG_20170912_0002.jpg
  ExifToolVersion = 10.61
  FileName = IMG_20170912_0002.jpg
  Directory = .
  FileSize = 1167147
  FileModifyDate = 1505194089.85091
  FileAccessDate = 1505194089.83525
  FileCreateDate = 1505193772.4216
  FilePermissions = 33206
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | ResolutionUnit = 1
  | XResolution = 300
  | YResolution = 300
  | ThumbnailWidth = 0
  | ThumbnailHeight = 0
JPEG APP1 (246 bytes):
  ExifByteOrder = MM
  + [IFD0 directory with 6 entries]
  | 0)  XResolution = 300 (300/1)
  | 1)  YResolution = 300 (300/1)
  | 2)  ResolutionUnit = 2
  | 3)  ModifyDate = 2017:09:12 00:00:00
  | 4)  YCbCrPositioning = 1
  | 5)  ExifOffset (SubDirectory) -->
  | + [ExifIFD directory with 6 entries]
  | | 0)  ExifVersion = 0231
  | | 1)  DateTimeOriginal = 2017:09:12 00:00:00
  | | 2)  CreateDate = 2017:09:12 00:00:00
  | | 3)  ComponentsConfiguration = 1 2 3 0
  | | 4)  FlashpixVersion = 0100
  | | 5)  ColorSpace = 65535
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0 (15 bytes):
  ImageWidth = 1788
  ImageHeight = 988
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
JPEG DHT (28 bytes):
JPEG DHT (85 bytes):
JPEG DHT (27 bytes):
JPEG DHT (93 bytes):
JPEG SOS
Why doesn't the ImageMagick convert tool preserve the tags from the TIFF file into the new JPEG file?
wumpus
Posts: 11
Joined: 2016-04-29T17:02:11-07:00
Authentication code: 1151

Re: convert doesn't like some EXIF tags

Post by wumpus »

Post Reply