{"record":{"id":"5b43b41402b422c7","repo":"SixLabors/ImageSharp","slug":"invalid-icc-profile","errorCode":null,"errorMessage":"Invalid ICC profile.","messagePattern":"Invalid ICC profile\\.","errorType":"exception","errorClass":"InvalidIccProfileException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs","lineNumber":706,"sourceCode":"            this.Metadata.ExifProfile = new ExifProfile(this.exifData);\n        }\n    }\n\n    /// <summary>\n    /// Initializes the ICC profile.\n    /// </summary>\n    private void InitIccProfile()\n    {\n        if (this.hasIcc && this.Metadata.IccProfile == null)\n        {\n            IccProfile profile = new(this.iccData);\n            if (profile.CheckIsValid())\n            {\n                this.Metadata.IccProfile = profile;\n            }\n            else\n            {\n                throw new InvalidIccProfileException(\"Invalid ICC profile.\");\n            }\n        }\n    }\n\n    private void SetIccMetadata(IccProfile profile)\n    {\n        if (!this.skipMetadata && profile?.CheckIsValid() == true)\n        {\n            this.hasIcc = true;\n            this.Metadata ??= new ImageMetadata();\n            this.Metadata.IccProfile = profile;\n        }\n    }\n\n    /// <summary>\n    /// Initializes the IPTC profile.\n    /// </summary>\n    private void InitIptcProfile()","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs#L688-L724","documentation":"JpegDecoderCore.InitIccProfile embeds an APP2 ICC profile into the metadata only if IccProfile.CheckIsValid() passes; otherwise it throws InvalidIccProfileException. The JPEG carries an ICC profile that fails the library's structural validation.","triggerScenarios":"Decoding a JPEG containing an ICC APP2 marker whose profile data is malformed (bad header, invalid tag table, truncated profile) so CheckIsValid() returns false.","commonSituations":"Images processed by tools that wrote broken/corrupt ICC profiles; truncated files cutting the ICC chunk mid-profile; hand-crafted or fuzzed JPEGs; profiles stripped of required tags by downstream pipelines.","solutions":["Strip or repair the ICC profile using an image tool (e.g. exiftool/exiv2 to remove the profile) and retry","Catch InvalidIccProfileException and decode without honoring color management","Re-export the image from the original source with a valid sRGB profile","Verify the file is not truncated — a partial profile is a common cause"],"exampleFix":"// before\nusing var image = Image.Load(stream); // InvalidIccProfileException\n// after\ntry { using var image = Image.Load(stream); }\ncatch (InvalidIccProfileException ex)\n{\n    // Remove ICC: exiftool -icc_profile= file.jpg, then reload\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { using var image = Image.Load(stream); }\ncatch (InvalidIccProfileException)\n{\n    // Strip the ICC profile externally and retry, or decode without color management\n}","preventionTips":["Sanitize uploads with exiftool/exiv2 to drop malformed ICC chunks","Watch for truncation — partial profiles are the usual cause","Regenerate profiles with a color management tool if you control the source"],"tags":["dotnet","jpeg","icc-profile","color-management"],"backgroundTag":"invalid-argument-format","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}