Imagesharp: ImageFormatException: DHT has wrong length: 0 in PdfJsJpegDecoderCore

Created on 22 Jun 2018  路  2Comments  路  Source: SixLabors/ImageSharp

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am running the latest version of ImageSharp
  • [x] I have verified if the problem exist in both DEBUG and RELEASE mode
  • [x] I have searched open and closed issues to ensure it has not already been reported

Description

PdfJsJpegDecoderCore throws ImageFormatException with message DHT has wrong length: 0 for a correct jpeg image. Here is description of the one of those images:

$ identify -verbose 1.jpeg

Image: 1.jpeg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1079x1080+0+0
  Units: Undefined
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 1165320
    Red:
      min: 5  (0.0196078)
      max: 255 (1)
      mean: 226.69 (0.888979)
      standard deviation: 65.0998 (0.255293)
      kurtosis: 3.85376
      skewness: -2.37351
      entropy: 0.328066
    Green:
      min: 6  (0.0235294)
      max: 255 (1)
      mean: 203.244 (0.797036)
      standard deviation: 90.5669 (0.355164)
      kurtosis: -0.337993
      skewness: -1.273
      entropy: 0.319966
    Blue:
      min: 5  (0.0196078)
      max: 255 (1)
      mean: 203.818 (0.799288)
      standard deviation: 89.3192 (0.350271)
      kurtosis: -0.347884
      skewness: -1.27022
      entropy: 0.320873
  Image statistics:
    Overall:
      min: 5  (0.0196078)
      max: 255 (1)
      mean: 211.251 (0.828434)
      standard deviation: 81.662 (0.320243)
      kurtosis: 0.47284
      skewness: -1.55094
      entropy: 0.322968
  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)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: JPEG
  Intensity: Undefined
  Compose: Over
  Page geometry: 1079x1080+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Orientation: Undefined
  Properties:
    date:create: 2018-06-22T15:00:41+07:00
    date:modify: 2018-06-22T14:47:29+07:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 10b2f139e0d1e2f440132a5a386faaf71d7f4ce71da2d69276c50ab04485d3de
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 49528B
  Number pixels: 1165320
  Pixels per second: 19.422MB
  User time: 0.040u
  Elapsed time: 0:01.059
  Version: ImageMagick 7.0.7-31 Q16 x86_64 2018-05-07 https://www.imagemagick.org

Steps to Reproduce

Call Image.Load for the one of attached images
images.zip

System Configuration

.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.300/

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba
  • ImageSharp version: 1.0.0-beta0004
  • Other ImageSharp packages and versions: SixLabors.ImageSharp.Drawing 1.0.0-beta0004
  • Environment (Operating system, version and so on): MacOS 10.12, Debian 9 (Linux)
  • .NET Framework version: .NET Core 2.1
bug

Most helpful comment

Turns out we were throwing when we didn't need to. Those progressive images have DHT markers with no following data, but the code could already handle that. I'll merge the PR as soon as it builds.

All 2 comments

Is there any fast workaround for this?

Turns out we were throwing when we didn't need to. Those progressive images have DHT markers with no following data, but the code could already handle that. I'll merge the PR as soon as it builds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vad3x picture vad3x  路  4Comments

JimBobSquarePants picture JimBobSquarePants  路  3Comments

antonfirsov picture antonfirsov  路  3Comments

marcpabst picture marcpabst  路  3Comments

Inumedia picture Inumedia  路  3Comments