Skip to content

Commit

Permalink
Leave comment explaining the situation
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenjudkins committed Apr 5, 2024
1 parent ec5a2e6 commit e3900f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/decoder/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,12 @@ impl Image {
let mut buffer = Vec::with_capacity(usize::try_from(compressed_length)?);
reader.take(compressed_length).read_to_end(&mut buffer)?;

// all extant tiff/fax4 decoders I've found always assume that the photometric interpretation
// is `WhiteIsZero`, ignoring the tag. ImageMagick appears to generate fax4-encoded tiffs
// with the tag incorrectly set to `BlackIsZero`.
fax::decoder::decode_g4(buffer.into_iter(), width, Some(height), |transitions| {
out.extend(fax::decoder::pels(transitions, width).map(|c| match c {
fax::Color::Black => 255, // fax4-encoded images in tiff files appear to be inverted from those in PDFs
fax::Color::Black => 255,
fax::Color::White => 0,
}))
});
Expand Down

0 comments on commit e3900f1

Please sign in to comment.