TIFF directory is missing required "ImageLength" field

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
sandy.ps4
Posts: 8
Joined: 2015-10-22T12:55:30-07:00
Authentication code: 1151

TIFF directory is missing required "ImageLength" field

Post by sandy.ps4 »

convert: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/553.
I'm getting this error while trying to convert a CR2 file (without extension) using the following command:

Code: Select all

convert -quiet test out.png
Even though an error is thrown, the conversion is successful and I can view out.png properly. Is this is a bug in ImageMagick? Thanks.

Result of

Code: Select all

 identify -verbose test
is below:

Image: test
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 5184x3456+0+0
Resolution: 72x72
Print size: 72x48
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: LSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 17915904
Red:
min: 10 (0.0392157)
max: 255 (1)
mean: 110.978 (0.435209)
standard deviation: 55.278 (0.216777)
kurtosis: -1.73738
skewness: -0.142265
entropy: 0.869265
Green:
min: 11 (0.0431373)
max: 253 (0.992157)
mean: 105.257 (0.412773)
standard deviation: 47.5014 (0.18628)
kurtosis: -1.49512
skewness: -0.233857
entropy: 0.876113
Blue:
min: 0 (0)
max: 245 (0.960784)
mean: 97.7112 (0.383181)
standard deviation: 39.6831 (0.15562)
kurtosis: -1.25609
skewness: -0.382004
entropy: 0.855306
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 104.649 (0.410388)
standard deviation: 47.9124 (0.187892)
kurtosis: -1.42075
skewness: -0.132388
entropy: 0.866895
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 5184x3456+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Orientation: TopLeft
Properties:
date:create: 2015-10-15T15:59:10-05:00
date:modify: 2015-10-15T15:23:10-05:00
exif:ApertureValue: 4.625
exif:CustomRendered: 0
exif:DateTimeDigitized: 2014:06:09 11:03:51
exif:DateTimeOriginal: 2014:06:09 11:03:51
exif:ExposureBiasValue: 0
exif:ExposureMode: 0
exif:ExposureProgram: 2
exif:ExposureTime: 0.02
exif:Flash: 16
exif:FNumber: 5
exif:FocalLength: 39
exif:FocalPlaneResolutionUnit: 2
exif:FocalPlaneXResolution: 5728.18
exif:FocalPlaneYResolution: 5808.4
exif:ISOSpeedRatings: 160
exif:MeteringMode: 5
exif:SceneCaptureType: 0
exif:ShutterSpeedValue: 5.625
exif:SubSecTime: 49
exif:SubSecTimeDigitized: 49
exif:SubSecTimeOriginal: 49
exif:WhiteBalance: 0
signature: 7f36e95011972b62a089a6301539599d3f9a8de381a9bafe76dcee29284ee935
tiff:alpha: unspecified
tiff:artist:
tiff:copyright:
tiff:endian: lsb
tiff:make: Canon
tiff:model: Canon EOS REBEL T3i
tiff:photometric: YCBCR
tiff:timestamp: 2014:06:09 11:03:51
xmp:Rating: 0
Profiles:
Profile-xmp: 8192 bytes
Artifacts:
filename: test
verbose: true
Tainted: False
Filesize: 22.84MB
Number pixels: 17.92M
Pixels per second: 255.94GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-07-26 http://www.imagemagick.org
identify: Photometric tag is missing, assuming data is YCbCr. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: SamplesPerPixel tag is missing, applying correct SamplesPerPixel value of 3. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Subsampling tag is not set, yet subsampling inside JPEG data [2,1] does not match default values [2,2]; assuming subsampling inside JPEG data is correct. `OJPEGSubsamplingCorrect' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 34864 (0x8830) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 34866 (0x8832) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Wrong data type 3 for "PixelXDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Wrong data type 3 for "PixelYDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 40965 (0xa005) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 42032 (0xa430) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 42034 (0xa432) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 42036 (0xa434) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 42037 (0xa435) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Photometric tag is missing, assuming data is YCbCr. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: SamplesPerPixel tag is missing, applying correct SamplesPerPixel value of 3. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Subsampling tag is not set, yet subsampling inside JPEG data [2,1] does not match default values [2,2]; assuming subsampling inside JPEG data is correct. `OJPEGSubsamplingCorrect' @ warning/tiff.c/TIFFWarnings/856.
identify: Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software. `OJPEGSetupDecode' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 513 (0x201) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: Unknown field with tag 514 (0x202) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/856.
identify: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/553.
Last edited by sandy.ps4 on 2015-10-23T12:40:28-07:00, edited 3 times in total.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: TIFF directory is missing required "ImageLength" field

Post by dlemstra »

What is your operating system and can you reproduce this issue with the latest version of ImageMagick? Please share your file on something like dropbox if you want us to have a look at it.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIFF directory is missing required "ImageLength" field

Post by fmw42 »

convert -quiet test out.png
If test is a TIFF file, it might help to add the proper suffix of .tif or .tiff.
sandy.ps4
Posts: 8
Joined: 2015-10-22T12:55:30-07:00
Authentication code: 1151

Re: TIFF directory is missing required "ImageLength" field

Post by sandy.ps4 »

dlemstra wrote:What is your operating system and can you reproduce this issue with the latest version of ImageMagick? Please share your file on something like dropbox if you want us to have a look at it.
I'm using a MAC OS X (10.9.5) and ImageMagick Version is 6.9.1-10. Actually those are CR2 files (Canon Raw File) whose extensions have been removed using mv command. You can find a sample image here (http://216.18.212.226/PRODS/canon-1dx/F ... 000050.CR2) which produces the same result.
sandy.ps4
Posts: 8
Joined: 2015-10-22T12:55:30-07:00
Authentication code: 1151

Re: TIFF directory is missing required "ImageLength" field

Post by sandy.ps4 »

fmw42 wrote:
convert -quiet test out.png
If test is a TIFF file, it might help to add the proper suffix of .tif or .tiff.
Yes, it works with an extension. These are actually CR2 files whose extensions have been removed. To put it differently, is having an extension a requirement for ImageMagick to work? In my application, the files are stored without extensions. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIFF directory is missing required "ImageLength" field

Post by fmw42 »

IM can usually detect the file type from the header for files that have headers. I am not sure if CR2 files have headers, if they are raw camera files.

I believe CR2 files need the DCRAW delegate library to be installed to handle them properly. However, I am not an expert on that. Perhaps one of the CR2 image users can explain or correct me.

You could also try

Code: Select all

convert -quiet TIF:test output.png
or

Code: Select all

convert -quiet TIFF:test output.png

see
http://www.imagemagick.org/Usage/formats/#crw
http://www.imagemagick.org/Usage/formats/#rgb


It is surprising that identify -verbose sees that it is a TIFF file, but convert will not process it properly.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TIFF directory is missing required "ImageLength" field

Post by snibgo »

sandy.ps4 wrote:To put it differently, is having an extension a requirement for ImageMagick to work? In my application, the files are stored without extensions. Thanks.
In brief, I think this is a bad idea.

More fully:

An extension isn't required. When there is no extension, IM processes this file as ".tiff". The processing for ".tiff" is different to ".cr2".

A CR2 file contains multiple images, including a 14-bit Bayer raw image, and a slightly trimmed version of this, as 8-bit JPEG.

If IM processes the file as .tiff, it gives you the 8-bit trimmed JPEG.

If IM processes the file as .cr2, it passes the file to dcraw for processing. Dcraw will read the raw image, de-Bayer etc and pass it back to IM as 16-bit with no loss, and IM will then do whatever you want.

For quick and dirty work, the 8-bit jpeg may do what you need. But if you want to apply any processing at all, you should start with as much data as you can get, and without the ringing introduced by the sharpening for the JPEG.

So dropping the file extension is a bad idea.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TIFF directory is missing required "ImageLength" field

Post by snibgo »

Look at extensions in a different way: a workflow should treat ordinary tiff files differently to Canon CR2 or Nikon NEF, even though they have the same format (more or less). Keeping extensions means scripts know what is needed from the filename. Dropping extensions means scripts have to open each file to find what images it contains, and life becomes complicated.
snibgo's IM pages: im.snibgo.com
sandy.ps4
Posts: 8
Joined: 2015-10-22T12:55:30-07:00
Authentication code: 1151

Re: TIFF directory is missing required "ImageLength" field

Post by sandy.ps4 »

Thanks for the detailed reply. I'll see if I can get around the extension issue. Thanks.
snibgo wrote:
sandy.ps4 wrote:To put it differently, is having an extension a requirement for ImageMagick to work? In my application, the files are stored without extensions. Thanks.
In brief, I think this is a bad idea.

More fully:

An extension isn't required. When there is no extension, IM processes this file as ".tiff". The processing for ".tiff" is different to ".cr2".

A CR2 file contains multiple images, including a 14-bit Bayer raw image, and a slightly trimmed version of this, as 8-bit JPEG.

If IM processes the file as .tiff, it gives you the 8-bit trimmed JPEG.

If IM processes the file as .cr2, it passes the file to dcraw for processing. Dcraw will read the raw image, de-Bayer etc and pass it back to IM as 16-bit with no loss, and IM will then do whatever you want.

For quick and dirty work, the 8-bit jpeg may do what you need. But if you want to apply any processing at all, you should start with as much data as you can get, and without the ringing introduced by the sharpening for the JPEG.

So dropping the file extension is a bad idea.
sandy.ps4
Posts: 8
Joined: 2015-10-22T12:55:30-07:00
Authentication code: 1151

Re: TIFF directory is missing required "ImageLength" field

Post by sandy.ps4 »

Thanks for the reply. It works like this

Code: Select all

convert -quiet CR2:test output.png
I was trying to get it to work without the extension. Anyways, thanks.
fmw42 wrote:IM can usually detect the file type from the header for files that have headers. I am not sure if CR2 files have headers, if they are raw camera files.

I believe CR2 files need the DCRAW delegate library to be installed to handle them properly. However, I am not an expert on that. Perhaps one of the CR2 image users can explain or correct me.

You could also try

Code: Select all

convert -quiet TIF:test output.png
or

Code: Select all

convert -quiet TIFF:test output.png

see
http://www.imagemagick.org/Usage/formats/#crw
http://www.imagemagick.org/Usage/formats/#rgb


It is surprising that identify -verbose sees that it is a TIFF file, but convert will not process it properly.
Post Reply