tiff to pdf conversion fails with "incorrect count"

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
edwinherald
Posts: 5
Joined: 2018-10-31T07:59:16-07:00
Authentication code: 1152

tiff to pdf conversion fails with "incorrect count"

Post by edwinherald »

convert pdferror.tiff output.pdf
convert: Incorrect count for "BitsPerSample". `TIFFReadDirectory' @ error/tiff.c/TIFFErrors/565.
convert: no images defined `output.pdf' @ error/convert.c/ConvertImageCommand/3253.
[wfuser@LOUAPPLTS70 es_im]$

This is occurring for only one document, anyone help on this what this error means and is it the issue with the document and how to resolve it?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: tiff to pdf conversion fails with "incorrect count"

Post by snibgo »

What version of IM? If old, try an upgrade.

What does exiftool say about that file?

Perhaps the input file is corrupt. Please provide a link to it.
snibgo's IM pages: im.snibgo.com
edwinherald
Posts: 5
Joined: 2018-10-31T07:59:16-07:00
Authentication code: 1152

Re: tiff to pdf conversion fails with "incorrect count"

Post by edwinherald »

When I checked the version, I found below.
convert -version
Version: ImageMagick 7.0.3-2 Q16 x86_64 2017-07-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC

Moreoever I don't have exiftool as I work inside a restricted customer environment but this tool was inside Workfusion platform

Also, you can't access the link as it inside the environment or share the document.

We know there is some issue in the document but we don't know why? If the file corrupted, it couldn't be open from tiff editor right?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: tiff to pdf conversion fails with "incorrect count"

Post by snibgo »

TIFF is a massively complex format. Perhaps this file uses an unusual combination of features that IM can't handle, eg JPEG with more than 8 bits/sample.

"-debug coder" will give some info, including "bits per sample".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: tiff to pdf conversion fails with "incorrect count"

Post by fmw42 »

IM 7.0.3.2 is rather old. It is currently 7.0.8.14.

Perhaps you need to upgrade it. Also check the version of TIFF perhaps upgrade that. You can check the tiff version from

magick -list format

and look at the end of the line for TIFF to find the version. For example mine is

TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.9)
edwinherald
Posts: 5
Joined: 2018-10-31T07:59:16-07:00
Authentication code: 1152

Re: tiff to pdf conversion fails with "incorrect count"

Post by edwinherald »

Thanks for the inputs, when I run the command - im -list format, here is what it outputs

[wfuser@LOUAPPLTS70 es_im]$ convert -list format
Format Module Mode Description
-------------------------------------------------------------------------------
3FR DNG r-- Hasselblad CFV/H3D39II
AAI* AAI rw+ AAI Dune image
AI PDF rw- Adobe Illustrator CS2
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format
AVI MPEG r-- Microsoft Audio/Visual Interleaved
AVS* AVS rw+ AVS X image
BGR* BGR rw+ Raw blue, green, and red samples
BGRA* BGR rw+ Raw blue, green, red, and alpha samples
BGRO* BGR rw+ Raw blue, green, red, and opacity samples
BMP* BMP rw- Microsoft Windows bitmap image
BMP2* BMP -w- Microsoft Windows bitmap image (V2)
BMP3* BMP -w- Microsoft Windows bitmap image (V3)
BRF* BRAILLE -w- BRF ASCII Braille format
CAL* CALS rw- Continuous Acquisition and Life-cycle Support Type 1
Specified in MIL-R-28002 and MIL-PRF-28002
CALS* CALS rw- Continuous Acquisition and Life-cycle Support Type 1
Specified in MIL-R-28002 and MIL-PRF-28002
CANVAS* XC r-- Constant image uniform color
CAPTION* CAPTION r-- Caption
CIN* CIN rw- Cineon Image File
CIP* CIP -w- Cisco IP phone image format
CLIP* CLIP rw+ Image Clip Mask
CMYK* CMYK rw+ Raw cyan, magenta, yellow, and black samples
CMYKA* CMYK rw+ Raw cyan, magenta, yellow, black, and alpha samples
CR2 DNG r-- Canon Digital Camera Raw Image Format
CRW DNG r-- Canon Digital Camera Raw Image Format
CUR* ICON rw- Microsoft icon
CUT* CUT r-- DR Halo
DCM* DCM r-- Digital Imaging and Communications in Medicine image
DICOM is used by the medical community for images like X-rays. The
specification, "Digital Imaging and Communications in Medicine
(DICOM)", is available at http://medical.nema.org/. In particular,
see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
and supplement 61 which adds JPEG-2000 encoding.
DCR DNG r-- Kodak Digital Camera Raw Image File
DCX* PCX rw+ ZSoft IBM PC multi-page Paintbrush
DDS* DDS rw+ Microsoft DirectDraw Surface
DFONT* TTF r-- Multi-face font package (Freetype 2.4.11)
DNG DNG r-- Digital Negative
DOT DOT --- Graphviz
DPX* DPX rw- SMPTE 268M-2003 (DPX 2.0)
Digital Moving Picture Exchange Bitmap, Version 2.0.
See SMPTE 268M-2003 specification at http://www.smtpe.org

DXT1* DDS rw+ Microsoft DirectDraw Surface
DXT5* DDS rw+ Microsoft DirectDraw Surface
EPDF PDF rw- Encapsulated Portable Document Format
EPI PS rw- Encapsulated PostScript Interchange format
EPS PS rw- Encapsulated PostScript
EPS2* PS2 -w- Level II Encapsulated PostScript
EPS3* PS3 -w+ Level III Encapsulated PostScript
EPSF PS rw- Encapsulated PostScript
EPSI PS rw- Encapsulated PostScript Interchange format
EPT EPT rw- Encapsulated PostScript with TIFF preview
EPT2 EPT rw- Encapsulated PostScript Level II with TIFF preview
EPT3 EPT rw+ Encapsulated PostScript Level III with TIFF preview
ERF DNG r-- Epson RAW Format
FAX* FAX rw+ Group 3 FAX
FAX machines use non-square pixels which are 1.5 times wider than
they are tall but computer displays use square pixels, therefore
FAX images may appear to be narrow unless they are explicitly
resized using a geometry of "150x100%".

FILE* URL r-- Uniform Resource Locator (file://)
FITS* FITS rw- Flexible Image Transport System
FRACTAL* PLASMA r-- Plasma fractal image
FTP* URL --- Uniform Resource Locator (ftp://)
FTS* FITS rw- Flexible Image Transport System
G3* FAX rw- Group 3 FAX
G4* FAX rw- Group 4 FAX
GIF* GIF rw+ CompuServe graphics interchange format
GIF87* GIF rw- CompuServe graphics interchange format (version 87a)
GRADIENT* GRADIENT r-- Gradual linear passing from one shade to another
GRAY* GRAY rw+ Raw gray samples
GROUP4* TIFF rw- Raw CCITT Group4
GV DOT --- Graphviz
HALD* HALD r-- Identity Hald color lookup table image
HDR* HDR rw+ Radiance RGBE image format
HISTOGRAM* HISTOGRAM -w- Histogram of the image
HRZ* HRZ rw- Slow Scan TeleVision
HTM* HTML -w- Hypertext Markup Language and a client-side image map
HTML* HTML -w- Hypertext Markup Language and a client-side image map
HTTP* URL --- Uniform Resource Locator (http://)
HTTPS* URL --- Uniform Resource Locator (https://)
ICB* TGA rw- Truevision Targa image
ICO* ICON rw+ Microsoft icon
ICON* ICON rw- Microsoft icon
IIQ DNG r-- Phase One Raw Image Format
INFO INFO -w+ The image format and characteristics
INLINE* INLINE rw+ Base64-encoded inline images
IPL* IPL rw+ IPL Image Sequence
ISOBRL* BRAILLE -w- ISO/TR 11548-1 format
ISOBRL6* BRAILLE -w- ISO/TR 11548-1 format 6dot
JNG* PNG rw- JPEG Network Graphics
See http://www.libpng.org/pub/mng/ for details about the JNG
format.
JNX* JNX r-- Garmin tile format
JPE* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JPG* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JPS* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JSON JSON -w+ The image format and characteristics
K25 DNG r-- Kodak Digital Camera Raw Image Format
KDC DNG r-- Kodak Digital Camera Raw Image Format
LABEL* LABEL r-- Image label
M2V MPEG rw+ MPEG Video Stream
M4V MPEG rw+ Raw MPEG-4 Video
MAC* MAC r-- MAC Paint
MAP* MAP rw- Colormap intensities and indices
MASK* MASK rw+ Image Clip Mask
MAT MAT rw+ MATLAB level 5 image format
MATTE* MATTE -w+ MATTE format
MEF DNG r-- Mamiya Raw Image File
MIFF* MIFF rw+ Magick Image File Format
MKV MPEG rw+ Multimedia Container
MNG* PNG rw+ Multiple-image Network Graphics (libpng 1.5.13)
See http://www.libpng.org/pub/mng/ for details about the MNG
format.
MONO* MONO rw- Raw bi-level bitmap
MOV MPEG rw+ MPEG Video Stream
MP4 MPEG rw+ MPEG-4 Video Stream
MPC* MPC rw+ Magick Persistent Cache image format
MPEG MPEG rw+ MPEG Video Stream
MPG MPEG rw+ MPEG Video Stream
MRW DNG r-- Sony (Minolta) Raw Image File
MSL* MSL --- Magick Scripting Language
MSVG SVG -w+ ImageMagick's own SVG internal renderer
MTV* MTV rw+ MTV Raytracing image format
MVG* MVG rw- Magick Vector Graphics
NEF DNG r-- Nikon Digital SLR Camera Raw Image File
NRW DNG r-- Nikon Digital SLR Camera Raw Image File
NULL* NULL rw- Constant image of uniform color
ORF DNG r-- Olympus Digital Camera Raw Image File
OTB* OTB rw- On-the-air bitmap
OTF* TTF r-- Open Type font (Freetype 2.4.11)
PAL* UYVY rw- 16bit/pixel interleaved YUV
PALM* PALM rw+ Palm pixmap
PAM* PNM rw+ Common 2-dimensional bitmap format
PANGO* PANGO --- Pango Markup Language
PATTERN* PATTERN r-- Predefined pattern
PBM* PNM rw+ Portable bitmap format (black and white)
PCD* PCD rw- Photo CD
PCDS* PCD rw- Photo CD
PCL PCL rw+ Printer Control Language
PCT* PICT rw- Apple Macintosh QuickDraw/PICT
PCX* PCX rw- ZSoft IBM PC Paintbrush
PDB* PDB rw+ Palm Database ImageViewer Format
PDF PDF rw+ Portable Document Format
PDFA PDF rw+ Portable Document Archive Format
PEF DNG r-- Pentax Electronic File
PES* PES r-- Embrid Embroidery Format
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.4.11)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.4.11)
PFM* PNM rw+ Portable float format
PGM* PNM rw+ Portable graymap format (gray scale)
PICON* XPM rw- Personal Icon
PICT* PICT rw- Apple Macintosh QuickDraw/PICT
PIX* PIX r-- Alias/Wavefront RLE image format
PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (62)
PLASMA* PLASMA r-- Plasma fractal image
PNG* PNG rw- Portable Network Graphics (libpng 1.5.13)
See http://www.libpng.org/ for details about the PNG format.
PNG00* PNG rw- PNG inheriting bit-depth, color-type from original, if possible
PNG24* PNG rw- opaque or binary transparent 24-bit RGB (zlib 1.2.7)
PNG32* PNG rw- opaque or transparent 32-bit RGBA
PNG48* PNG rw- opaque or binary transparent 48-bit RGB
PNG64* PNG rw- opaque or transparent 64-bit RGBA
PNG8* PNG rw- 8-bit indexed with optional binary transparency
PNM* PNM rw+ Portable anymap
PPM* PNM rw+ Portable pixmap format (color)
PS PS rw+ PostScript
PS2* PS2 -w+ Level II PostScript
PS3* PS3 -w+ Level III PostScript
PSB* PSD rw+ Adobe Large Document Format
PSD* PSD rw+ Adobe Photoshop bitmap
PTIF* TIFF rw+ Pyramid encoded TIFF
PWP* PWP r-- Seattle Film Works
RADIAL-GRADIENT* GRADIENT r-- Gradual radial passing from one shade to another
RAF DNG r-- Fuji CCD-RAW Graphic File
RAS* SUN rw+ SUN Rasterfile
RAW DNG r-- Raw
RGB* RGB rw+ Raw red, green, and blue samples
RGBA* RGB rw+ Raw red, green, blue, and alpha samples
RGBO* RGB rw+ Raw red, green, blue, and opacity samples
RGF* RGF rw- LEGO Mindstorms EV3 Robot Graphic Format (black and white)
RLA* RLA r-- Alias/Wavefront image
RLE* RLE r-- Utah Run length encoded image
RMF DNG r-- Raw Media Format
RW2 DNG r-- Panasonic Lumix Raw Image
SCR* SCR r-- ZX-Spectrum SCREEN$
SCT* SCT r-- Scitex HandShake
SFW* SFW r-- Seattle Film Works
SGI* SGI rw+ Irix RGB image
SHTML* HTML -w- Hypertext Markup Language and a client-side image map
SIX* SIX rw- DEC SIXEL Graphics Format
SIXEL* SIXEL rw- DEC SIXEL Graphics Format
SPARSE-COLOR* TXT -w+ Sparse Color
SR2 DNG r-- Sony Raw Format 2
SRF DNG r-- Sony Raw Format
STEGANO* STEGANO r-- Steganographic image
SUN* SUN rw+ SUN Rasterfile
SVG SVG -w+ Scalable Vector Graphics
SVGZ SVG -w+ Compressed Scalable Vector Graphics
TEXT* TXT r-- Text
TGA* TGA rw- Truevision Targa image
THUMBNAIL* THUMBNAIL -w+ EXIF Profile Thumbnail
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.3)
TIFF64* TIFF rw- Tagged Image File Format (64-bit) (LIBTIFF, Version 4.0.3)
TILE* TILE r-- Tile image with a texture
TIM* TIM r-- PSX TIM
TTC* TTF r-- TrueType font collection (Freetype 2.4.11)
TTF* TTF r-- TrueType font (Freetype 2.4.11)
TXT* TXT rw+ Text
UBRL* BRAILLE -w- Unicode Text format
UBRL6* BRAILLE -w- Unicode Text format 6dot
UIL* UIL -w- X-Motif UIL table
UYVY* UYVY rw- 16bit/pixel interleaved YUV
VDA* TGA rw- Truevision Targa image
VICAR* VICAR rw- VICAR rasterfile format
VID* VID rw+ Visual Image Directory
VIFF* VIFF rw+ Khoros Visualization image
VIPS* VIPS rw+ VIPS image
VST* TGA rw- Truevision Targa image
WBMP* WBMP rw- Wireless Bitmap (level 0) image
WMV MPEG rw+ Windows Media Video
WPG* WPG r-- Word Perfect Graphics
X3F DNG r-- Sigma Camera RAW Picture File
XBM* XBM rw- X Windows system bitmap (black and white)
XC* XC r-- Constant image uniform color
XCF* XCF r-- GIMP image
XPM* XPM rw- X Windows system pixmap (color)
XPS XPS r-- Microsoft XML Paper Specification
XV* VIFF rw+ Khoros Visualization image
YCbCr* YCbCr rw+ Raw Y, Cb, and Cr samples
YCbCrA* YCbCr rw+ Raw Y, Cb, Cr, and alpha samples
YUV* YUV rw- CCIR 601 4:1:1 or 4:2:2

* native blob support
r read support
w write support
+ support for multiple images

and the output of - convert pdferror.tiff output.pdf -debug coder is as below.

[wfuser@LOUAPPLTS70 es_im]$ convert pdferror.tiff output.pdf -debug coder and can you provide some highlights on below

2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadPNGImage/3977/Coder
Enter ReadPNGImage()
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2055/Coder
Enter ReadOnePNGImage()
IM version = 7.0.3-2
Libpng version = 1.5.13
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2068/Coder
Zlib version = 1.2.7
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2100/Coder
Before reading:
image->alpha_trait=0 image->rendering_intent=2
image->colorspace=23
image->gamma=0.454545
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2389/Coder
PNG width: 613, height: 863
PNG color_type: 6, bit_depth: 8
PNG compression_method: 0
PNG interlace_method: 0, filter_method: 0
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2659/Coder
Setting sRGB as if in input
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2710/Coder
Reading PNG pHYs chunk: xres: 2835, yres: 2835, units: 1.
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2818/Coder
Reading PNG bKGD chunk, raw ping_background=(65535,65535,65535).
bkgd_scale=257. ping_background=(65535,65535,65535).
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2839/Coder
image->background_color=(65535,65535,65535).
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/2975/Coder
image->colorspace=23
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3146/Coder
Reading PNG IDAT chunk(s)
2018-10-31T19:39:16-04:00 0:00.160 0.000u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3164/Coder
Converting PNG pixels to pixel packets
2018-10-31T19:39:16-04:00 0:00.160 0.010u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3238/Coder
Looking for cheap transparent pixel
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3481/Coder
No transparent pixel was found
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3507/Coder
image->storage_class=1

2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3630/Coder
Reading PNG text chunk
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3684/Coder
length: 20
Keyword: Software
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadOnePNGImage/3930/Coder
exit ReadOnePNGImage()
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadPNGImage/4056/Coder
page.w: 0, page.h: 0,page.x: 0, page.y: 0.
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadPNGImage/4060/Coder
image->colorspace: 23
2018-10-31T19:39:16-04:00 0:00.180 0.030u 7.0.3 Coder convert[18989]: png.c/ReadPNGImage/4065/Coder
exit ReadPNGImage()
convert: Incorrect count for "BitsPerSample". `TIFFReadDirectory' @ error/tiff.c/TIFFErrors/565.
convert: `coder' @ error/convert.c/ConvertImageCommand/3250.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: tiff to pdf conversion fails with "incorrect count"

Post by fmw42 »

Your TIFF version is 4.0.3. So a bit older than my 4.0.9. You might try upgrading it. Also upgrade ImageMagick as it is rather old. I don't guarantee that it will make a difference. It could be other issues and truly corrupt, which seems likely from the error message. But perhaps TIFF 4.0.3 had a bug.

Is the image proprietary? If not, then you could post it to some free hosting service such as dropbox.com and put the URL here so we can test with it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: tiff to pdf conversion fails with "incorrect count"

Post by snibgo »

edwinherald wrote: convert pdferror.tiff output.pdf -debug coder
:
:
convert: `coder' @ error/convert.c/ConvertImageCommand/3250.
You can see your command created an error. We want to debug the read of the input tiff, so please try again with "-debug coder" before the input file.
snibgo's IM pages: im.snibgo.com
edwinherald
Posts: 5
Joined: 2018-10-31T07:59:16-07:00
Authentication code: 1152

Re: tiff to pdf conversion fails with "incorrect count"

Post by edwinherald »

when running the command like this convert -debug coder pdferror.tiff output.pdf , it just throwing "Incorrect count" error.

Let me know what is the right way to pass this.

Also, I will check with customer whether I can share the document through dropbox
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: tiff to pdf conversion fails with "incorrect count"

Post by fmw42 »

Do you get any other data besides that error when you do

Code: Select all

identify -verbose pdferror.tiff
If you get lots of warnings (not errors), then try

Code: Select all

identify -verbose -quiet pdferror.tiff
edwinherald
Posts: 5
Joined: 2018-10-31T07:59:16-07:00
Authentication code: 1152

Re: tiff to pdf conversion fails with "incorrect count"

Post by edwinherald »

Other than "Incorrect count for "BitsPerSample", I didn't get any other error.

When I issue, the command - identify -verbose pdferror.tiff, it says incorrect command.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: tiff to pdf conversion fails with "incorrect count"

Post by fmw42 »

On IM 7, the correct command would be

magick identify -verbose pdferror.tiff

Syntax has changed a bit in IM 7.
Post Reply