Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPEG: Fix decoding of images with invalid color metadata #3843

Closed
graciousgrey opened this issue Oct 24, 2023 Discussed in #3782 · 5 comments
Closed

JPEG: Fix decoding of images with invalid color metadata #3843

graciousgrey opened this issue Oct 24, 2023 Discussed in #3782 · 5 comments
Assignees
Labels
bug Something isn't working released Available in the stable release tested Changes have been tested successfully

Comments

@graciousgrey
Copy link
Member

The mentioned file below can only be indexed if the exif metadata is removed. The mime type matches the file extension.

Acceptance Criteria:

  • Check what part of the photo's metadata causes indexing to fail.
  • Check if we can fix the metadata so that the file can be indexed.
 "ExifToolVersion": 12.40,
  "Directory": ".",
  "FileSize": "2.5 MiB",
  "FileModifyDate": "2023:10:24 13:18:51+02:00",
  "FileAccessDate": "2023:10:24 13:19:24+02:00",
  "FileInodeChangeDate": "2023:10:24 13:19:23+02:00",
  "FilePermissions": "-rw-rw-r--",
  "FileType": "JPEG",
  "FileTypeExtension": "jpg",
  "MIMEType": "image/jpeg",
  "ExifByteOrder": "Little-endian (Intel, II)",
  "ImageDescription": "",
  "Make": "vivo",
  "Model": "V2037",
  "Orientation": "Unknown (0)",
  "XResolution": 72,
  "YResolution": 72,
  "ResolutionUnit": "inches",
  "Software": "MediaTek Camera Application",
  "ModifyDate": "2023:10:01 13:49:23",
  "YCbCrPositioning": "Co-sited",
  "ExposureTime": "1/7299",
  "FNumber": 2.2,
  "ExposureProgram": "Not Defined",
  "ISO": 105,
  "SensitivityType": "Unknown",
  "RecommendedExposureIndex": 0,
  "ExifVersion": "0220",
  "DateTimeOriginal": "2023:10:01 13:49:23",
  "CreateDate": "2023:10:01 13:49:23",
  "ComponentsConfiguration": "Y, Cb, Cr, -",
  "ShutterSpeedValue": "1/7297",
  "BrightnessValue": 0,
  "ExposureCompensation": 0,
  "MaxApertureValue": 2.0,
  "MeteringMode": "Center-weighted average",
  "LightSource": "Other",
  "Flash": "No Flash",
  "FocalLength": "3.7 mm",
  "Warning": "Invalid EXIF text encoding for UserComment",
  "UserComment": "filter: 0; jpegRotation: 90; fileterIntensity: 0.000000; filterMask: 0; ",
  "SubSecTime": 549,
  "SubSecTimeOriginal": 549,
  "SubSecTimeDigitized": 549,
  "FlashpixVersion": "0100",
  "ColorSpace": "sRGB",
  "ExifImageWidth": 2340,
  "ExifImageHeight": 4160,
  "InteropIndex": "R98 - DCF basic file (sRGB)",
  "InteropVersion": "0100",
  "ExposureMode": "Auto",
  "WhiteBalance": "Auto",
  "DigitalZoomRatio": 1,
  "FocalLengthIn35mmFormat": "27 mm",
  "SceneCaptureType": "Standard",
  "GPSVersionID": "0.0.0.0",
  "GPSLatitudeRef": "Unknown ()",
  "GPSLongitudeRef": "Unknown ()",
  "GPSAltitudeRef": "Above Sea Level",
  "GPSAltitude": "undef",
  "GPSTimeStamp": "00:00:00",
  "GPSProcessingMethod": "",
  "GPSDateStamp": "",
  "Compression": "JPEG (old-style)",
  "ThumbnailOffset": 1664,
  "ThumbnailLength": 63744,
  "ImageWidth": 2340,
  "ImageHeight": 4160,
  "EncodingProcess": "Baseline DCT, Huffman coding",
  "BitsPerSample": 8,
  "ColorComponents": 3,
  "YCbCrSubSampling": "YCbCr4:2:0 (2 2)",
  "Aperture": 2.2,
  "ImageSize": "2340x4160",
  "Megapixels": 9.7,
  "ScaleFactor35efl": 7.4,
  "ShutterSpeed": "1/7299",
  "SubSecCreateDate": "2023:10:01 13:49:23.549",
  "SubSecDateTimeOriginal": "2023:10:01 13:49:23.549",
  "SubSecModifyDate": "2023:10:01 13:49:23.549",
  "ThumbnailImage": "(Binary data 63744 bytes, use -b option to extract)",
  "GPSDateTime": " 00:00:00Z",
  "GPSLatitude": "",
  "GPSLongitude": "",
  "CircleOfConfusion": "0.004 mm",
  "FOV": "67.4 deg",
  "FocalLength35efl": "3.7 mm (35 mm equivalent: 27.0 mm)",
  "HyperfocalDistance": "1.49 m",
  "LightValue": 15.0

Discussed in #3782

Originally posted by picklerick323 October 3, 2023
I have been getting this error in a couple of photos that I upload. I've attached a photo that gives me the error.

thumb: unrecognised image format in 20231001_134923_0D85D20D.jpg (read color metadata)
2023-10-02 16:31:25
index: failed creating thumbnails for 2023/10/20231001_134923_0D85D20D.jpg (image: unknown format while decoding)
2023-10-02 16:31:25

20231001_134923_0D85D20D

@graciousgrey graciousgrey added the enhancement Optimization, improvement or maintenance task label Oct 24, 2023
@lastzero
Copy link
Member

Might be caused by the GPS position data, which probably makes our parser throw an error.

@graciousgrey
Copy link
Member Author

I still get the error even if I remove all GPS data from the file.

@lastzero
Copy link
Member

Might still be cached in the json file unless you tested it on a new instance with no existing files?

@graciousgrey
Copy link
Member Author

The instance was reset and the sidecar folder was deleted.

@lastzero lastzero changed the title Metadata: Repair broken files JPEG: Explicitly read files with invalid color metadata from the beginning to avoid decoding errors Oct 31, 2023
@lastzero lastzero changed the title JPEG: Explicitly read files with invalid color metadata from the beginning to avoid decoding errors JPEG: Read files with invalid color data from the beginning Oct 31, 2023
lastzero added a commit that referenced this issue Oct 31, 2023
Using a ReadSeeker is necessary to read images with invalid color
metadata from the beginning in order to avoid decoding errors.

Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero
Copy link
Member

@lastzero lastzero added please-test Ready for acceptance test bug Something isn't working and removed enhancement Optimization, improvement or maintenance task labels Oct 31, 2023
@lastzero lastzero changed the title JPEG: Read files with invalid color data from the beginning JPEG: Files with invalid color metadata must be decoded from the beginning Oct 31, 2023
@lastzero lastzero changed the title JPEG: Files with invalid color metadata must be decoded from the beginning JPEG: Fix decoding of images with invalid color metadata Oct 31, 2023
lastzero added a commit that referenced this issue Nov 9, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
@graciousgrey graciousgrey added tested Changes have been tested successfully and removed please-test Ready for acceptance test labels Nov 21, 2023
@graciousgrey graciousgrey added the released Available in the stable release label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Available in the stable release tested Changes have been tested successfully
Projects
Status: Release 🌈
Development

No branches or pull requests

2 participants