-
Notifications
You must be signed in to change notification settings - Fork 82
Description
When I run JHove on a valid JPEG, created by an iPhone dual camera, an error is thrown and the file is marked as not well-formed.
This is the JHove output:
➜ jhove -m JPEG-HUL IMG_1616.jpg
Jhove (Rel. 1.32.0, 2024-09-12)
Date: 2025-07-04 00:13:27 CEST
RepresentationInformation: IMG_1616.jpg
ReportingModule: JPEG-hul, Rel. 1.5.4 (2023-03-16)
LastModified: 2025-07-04 00:12:54 CEST
Size: 3723240
Format: JPEG
Version: 1.01
Status: Not well-formed
SignatureMatches:
JPEG-hul
ErrorMessage: Expected marker byte 255 : Read marker byte value 65
ID: JPEG-HUL-7
Offset: 21
MIMEtype: image/jpeg
On this sample image: https://www.jianguoyun.com/p/DZou8ewQgsqOBxjb-Ho
Below is a screenshot of the hex-editor of the first few bytes:
APP0 starts at position 0x02 with marker '0xFF 0xE0' => OK
next word is at 0x04 -> 0x14 = 20 => OK
So next section is APP1 at postition 0x04 + 0x14 = 0x18, '0xFF 0xE1' => OK
But JHove starts reading the section at offset 21 (0x14) => Not OK
I found the code at
jhove/jhove-modules/jpeg-hul/src/main/java/edu/harvard/hul/ois/jhove/module/JpegModule.java
Line 1060 in d2676c9
| skipBytes(_dstream, 3 * xThumbPix * yThumbPix, this); |
Apparently, in this case Apple has added the 4 bytes 'A', 'M', 'P', 'F' to the end of the regular APP0 and added 4 to the length value of the APP0. This makes this JPEG a bit special, but still well-formed.
See also the remark in the ExifTools code at https://github.com/exiftool/exiftool/blob/a755221b7937406a16b40bcd533e992aa8b5caa0/lib/Image/ExifTool.pm#L2251
