Added unsupported error for interpretations not supported by JPEG
This commit is contained in:
1 parent
7307e96782
commit
4f1c88e35f
2 files changed
+15
-7
No files matched your search
@@ -358,7 +358,6 @@ impl Image {
|
||||
PhotometricInterpretation::BlackIsZero => {
|
||||
decoder.set_color_transform(jpeg::ColorTransform::None)
|
||||
}
|
||||
PhotometricInterpretation::RGBPalette => todo!(),
|
||||
PhotometricInterpretation::TransparencyMask => {
|
||||
decoder.set_color_transform(jpeg::ColorTransform::None)
|
||||
}
|
||||
@@ -368,8 +367,13 @@ impl Image {
|
||||
PhotometricInterpretation::YCbCr => {
|
||||
decoder.set_color_transform(jpeg::ColorTransform::YCbCr)
|
||||
}
|
||||
PhotometricInterpretation::CIELab => todo!(),
|
||||
_ => todo!(),
|
||||
photometric_interpretation => {
|
||||
return Err(TiffError::UnsupportedError(
|
||||
TiffUnsupportedError::UnsupportedInterpretation(
|
||||
photometric_interpretation,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let data = decoder.decode()?;
|
||||
|
||||
+8
-4
@@ -148,10 +148,8 @@ pub enum TiffUnsupportedError {
|
||||
UnsupportedBitsPerChannel(u8),
|
||||
UnsupportedPlanarConfig(Option<PlanarConfiguration>),
|
||||
UnsupportedDataType,
|
||||
UnsupportedInterpretation(PhotometricInterpretation),
|
||||
UnsupportedJpegFeature(UnsupportedFeature),
|
||||
#[doc(hidden)]
|
||||
/// Do not match against this variant. It may get removed.
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
impl fmt::Display for TiffUnsupportedError {
|
||||
@@ -197,10 +195,16 @@ impl fmt::Display for TiffUnsupportedError {
|
||||
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
|
||||
}
|
||||
UnsupportedDataType => write!(fmt, "Unsupported data type."),
|
||||
UnsupportedInterpretation(interpretation) => {
|
||||
write!(
|
||||
fmt,
|
||||
"Unsupported photometric interpretation \"{:?}\".",
|
||||
interpretation
|
||||
)
|
||||
}
|
||||
UnsupportedJpegFeature(ref unsupported_feature) => {
|
||||
write!(fmt, "Unsupported JPEG feature {:?}", unsupported_feature)
|
||||
}
|
||||
__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user