mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx/TIFF: Manually check for the presence of two baseline tags
Namely: BitsPerSample and SamplesPerPixel.
This commit is contained in:
parent
23d8d217ed
commit
8fb9c72c56
Notes:
sideshowbarker
2024-07-17 05:02:42 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/8fb9c72c56 Pull-request: https://github.com/SerenityOS/serenity/pull/24237 Reviewed-by: https://github.com/nico ✅
2 changed files with 8 additions and 2 deletions
|
@ -103,6 +103,12 @@ public:
|
|||
if (!m_metadata.rows_per_strip().has_value() && segment_byte_counts()->size() != 1 && !is_tiled())
|
||||
return Error::from_string_literal("TIFFImageDecoderPlugin: RowsPerStrip is not provided and impossible to deduce");
|
||||
|
||||
if (!m_metadata.bits_per_sample().has_value())
|
||||
return Error::from_string_literal("TIFFImageDecoderPlugin: Tag BitsPerSample is missing");
|
||||
|
||||
if (!m_metadata.samples_per_pixel().has_value())
|
||||
return Error::from_string_literal("TIFFImageDecoderPlugin: Tag SamplesPerPixel is missing");
|
||||
|
||||
if (any_of(*m_metadata.bits_per_sample(), [](auto bit_depth) { return bit_depth == 0 || bit_depth > 32; }))
|
||||
return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid value in BitsPerSample");
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ Tag = namedtuple(
|
|||
known_tags: List[Tag] = [
|
||||
Tag('256', [TIFFType.UnsignedShort, TIFFType.UnsignedLong], [1], None, "ImageWidth", is_required=True),
|
||||
Tag('257', [TIFFType.UnsignedShort, TIFFType.UnsignedLong], [1], None, "ImageLength", is_required=True),
|
||||
Tag('258', [TIFFType.UnsignedShort], [], None, "BitsPerSample", is_required=True),
|
||||
Tag('258', [TIFFType.UnsignedShort], [], None, "BitsPerSample", is_required=False),
|
||||
Tag('259', [TIFFType.UnsignedShort], [1], None, "Compression", Compression, is_required=True),
|
||||
Tag('262', [TIFFType.UnsignedShort], [1], None, "PhotometricInterpretation",
|
||||
PhotometricInterpretation, is_required=True),
|
||||
|
@ -134,7 +134,7 @@ known_tags: List[Tag] = [
|
|||
Tag('272', [TIFFType.ASCII], [], None, "Model"),
|
||||
Tag('273', [TIFFType.UnsignedShort, TIFFType.UnsignedLong], [], None, "StripOffsets", is_required=False),
|
||||
Tag('274', [TIFFType.UnsignedShort], [1], Orientation.Default, "Orientation", Orientation),
|
||||
Tag('277', [TIFFType.UnsignedShort], [1], None, "SamplesPerPixel", is_required=True),
|
||||
Tag('277', [TIFFType.UnsignedShort], [1], None, "SamplesPerPixel", is_required=False),
|
||||
Tag('278', [TIFFType.UnsignedShort, TIFFType.UnsignedLong], [1], None, "RowsPerStrip", is_required=False),
|
||||
Tag('279', [TIFFType.UnsignedShort, TIFFType.UnsignedLong], [], None, "StripByteCounts", is_required=False),
|
||||
Tag('282', [TIFFType.UnsignedRational], [1], None, "XResolution"),
|
||||
|
|
Loading…
Reference in a new issue