Skip to content

Commit 2738b3a

Browse files
Merge pull request #2483 from SixLabors/bp/Issue2451
Tiff: ccitt compression, fix for issue #2451
2 parents f88ec76 + 63aece9 commit 2738b3a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,29 @@ public bool ReadNextCodeWord()
125125
if (value == Len7Code0000000.Code)
126126
{
127127
this.Code = Len7Code0000000;
128-
return false;
128+
129+
// We do not support Extensions1D codes, but some encoders (scanner from epson) write a premature EOL code,
130+
// which at this point cannot be distinguished from the marker, because we read the data bit by bit.
131+
// Read the next 5 bit, if its a EOL code return true, indicating its the end of the image.
132+
if (this.ReadValue(5) == 1)
133+
{
134+
return true;
135+
}
136+
137+
throw new NotSupportedException("ccitt extensions 1D codes are not supported.");
129138
}
130139

131140
if (value == Len7Code0000001.Code)
132141
{
133142
this.Code = Len7Code0000001;
134-
return false;
143+
144+
// Same as above, we do not support Extensions2D codes, but it could be a EOL instead.
145+
if (this.ReadValue(5) == 1)
146+
{
147+
return true;
148+
}
149+
150+
throw new NotSupportedException("ccitt extensions 2D codes are not supported.");
135151
}
136152

137153
if (value == Len7Code0000011.Code)

0 commit comments

Comments
 (0)