TiffWarnings/820

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
lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

TiffWarnings/820

Post by lothar » 2018-11-19T09:38:55-07:00

Hi,

this may in fact be a bug but I am posting this as a question a user might have.
I got a number of "tif" files from a scientific instrument which I can display. However, I need to get access to the comments added to the tif file as they contain information about how this image was acquired (instrument parameter). I have used this on other images before so I am using

$ identify -verbose 20181107-SRC-C7-0003.tif

It prints a lot of output and when it is (in my estimate) about to print the Comments: it exits with:

Version: ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org
identify: Unknown field with tag 50345 (0xc4a9) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/820.
identify: ASCII value for tag "ImageDescription" contains null byte in value; value incorrectly truncated during reading due to implementation limitations. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/820.

However, in display I can see the comments in the "Image Info" function:
[a lot of information]
Properties:
comment: [TemImageFile]
nstrument Name=...
ate=11/07/18
ime=3:12:48 p
ample=

I just noticed all the comments are missing their first character ! It is Instrument not nstrument Name

Anyhow, it seems that there may be a way to get the pure comment string(s) from an image; here the user question - how can I get the comments on the command line ?
I need the comments for further processing. Normally I run something like set comment [exec -- identify -verbos $filename_tif] in a tcl script.

Is there another way? Can one ask identify to ignore errors in tags since 'display' does not seem to care ?

OS: Centos 7 I tired the above 6.7.8 and 7.0.7 on another computer with the same result.

Thanks,
Lothar

snibgo
Posts: 11446
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TiffWarnings/820

Post by snibgo » 2018-11-19T10:03:12-07:00

Those are warnings, not errors, and shouldn't cause IM to exit.

I suggest you post a link to a sample TIF file.
snibgo's IM pages: im.snibgo.com

lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

Re: TiffWarnings/820

Post by lothar » 2018-11-19T10:30:47-07:00

Hi,

the tif file is 6MB. Is it okay to post ? (convert -resize does get them small but the comment disappears).

Lothar

User avatar
fmw42
Posts: 24735
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TiffWarnings/820

Post by fmw42 » 2018-11-19T10:41:24-07:00

6 MB is ok. But this forum does not allow direct uploads. So post your image to some free hosting service that will not modify your image such as dropbox.com and put the URL here.

What do you get from:

Code: Select all

convert image.tif -quiet -format "%c" info:
That should read the comment field only without showing the warnings. If there is an actual error, it will show the error.

See https://imagemagick.org/script/escape.php for %c and other information that you can access.

lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

Re: TiffWarnings/820

Post by lothar » 2018-11-19T11:27:38-07:00

$ convert 20181107-SRC-C7-0004.tif -quiet -format "%c" info:
# returns :
Print Size=7.060M1VLab (7650 Bottom Mount) XR41B

User avatar
fmw42
Posts: 24735
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TiffWarnings/820

Post by fmw42 » 2018-11-19T11:42:07-07:00

Post your image as suggested above so that we can inspect it.

lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

Re: TiffWarnings/820

Post by lothar » 2018-11-19T11:47:28-07:00

https://www.dropbox.com/s/akxvxri8vmo4p ... 1.tif?dl=0

Sorry took me a minute to reset my dropbox password.

snibgo
Posts: 11446
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TiffWarnings/820

Post by snibgo » 2018-11-19T12:38:14-07:00

The comment is in lines, with \r (carriage return) as the line delimiter. Many tools interpret \r by writing the next text line on the same line as the previous line.

Code: Select all

  Properties:\r\n
    comment: [TemImageFile]\r
Instrument Name=EM Lab (7650 Bottom Mount
Date=11/07/18\r
Time=12:57:15 p\r
Magnification=30000\r
Acc. Voltage=80.0kV\r
Lens Mode=HC-ZOOM1\r
Sample Name=SCR\r
Tilt Angle=-0.1\r
Stage X=-538.3\r
Stage Y= 421.2\r
Stage Xp=-464071\r
Stage Yp= 363095\r
Print Size=7.0\r\n
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 24735
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TiffWarnings/820

Post by fmw42 » 2018-11-19T12:42:27-07:00

ImageMagick identify -verbose is only see the following in the properties section. So only the last part of your comment about Print Size is picked up. Note that the field "comment" is missing.

Code: Select all

  Properties:
Print Size=7.095M1VLab (7650 Bottom Mount) XR41B
    date:create: 2018-11-19T11:38:26-08:00
    date:modify: 2018-11-19T11:38:26-08:00
    signature: abb0dff6e4e659ea429a2dceeb1649d8d633b40329999bdfe1663f5f7e022078
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: min-is-black
    tiff:rows-per-strip: 4

lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

Re: TiffWarnings/820

Post by lothar » 2018-11-19T14:38:04-07:00

Can you verify the error message ?
Is there a solution to this problem ? Again, I did not write the file I only need to extract parameters that were written as comments.
If it is \r instead of \n and if this were to output a long string in unix, I could deal with that but if identify crashes or prints nothing I cannot continue.

Thanks,
Lothar

snibgo
Posts: 11446
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TiffWarnings/820

Post by snibgo » 2018-11-19T15:41:57-07:00

Yes, the problem is \r, and "tr" cures it.

Without "tr":

Code: Select all

convert 20181107-SRC-C6-0001.tif -format "%c" info:
convert.exe: Unknown field with tag 50345 (0xc4a9) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/913.
Print Size=7.095M1VLab (7650 Bottom Mount) XR41B
With "tr":

Code: Select all

convert 20181107-SRC-C6-0001.tif -format "%c" info: |tr "\r" "\n"
convert.exe: Unknown field with tag 50345 (0xc4a9) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/913.
[TemImageFile]
Instrument Name=EM Lab (7650 Bottom Mount) XR41B
Date=11/07/18
Time=12:57:15 p
Magnification=30000
Acc. Voltage=80.0kV
Lens Mode=HC-ZOOM1
Sample Name=SCR
Tilt Angle=-0.1
Stage X=-538.3
Stage Y= 421.2
Stage Xp=-464071
Stage Yp= 363095
Print Size=7.0
EDIT: to add that "-quiet" can be used to suppress the warning.
snibgo's IM pages: im.snibgo.com

lothar
Posts: 6
Joined: 2018-11-19T09:22:32-07:00
Authentication code: 1152

Re: TiffWarnings/820

Post by lothar » 2018-11-19T16:14:43-07:00

Cool thanks !

Post Reply