Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/chroma_subsampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,3 @@ pub(crate) enum ChromaSubsampling {
#[strum(serialize = "4:4:4")]
Yuv444,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn display() {
#[track_caller]
fn case(subsampling: ChromaSubsampling, expected: &str) {
assert_eq!(subsampling.to_string(), expected);
}

case(ChromaSubsampling::Yuv400, "4:0:0");
case(ChromaSubsampling::Yuv420, "4:2:0");
case(ChromaSubsampling::Yuv422, "4:2:2");
case(ChromaSubsampling::Yuv440, "4:4:0");
case(ChromaSubsampling::Yuv444, "4:4:4");
}

#[test]
fn serialize() {
#[track_caller]
fn case(subsampling: ChromaSubsampling, expected: &str) {
assert_eq!(serde_json::to_string(&subsampling).unwrap(), expected);
}

case(ChromaSubsampling::Yuv400, r#""4:0:0""#);
case(ChromaSubsampling::Yuv420, r#""4:2:0""#);
case(ChromaSubsampling::Yuv422, r#""4:2:2""#);
case(ChromaSubsampling::Yuv440, r#""4:4:0""#);
case(ChromaSubsampling::Yuv444, r#""4:4:4""#);
}
}
22 changes: 22 additions & 0 deletions src/color_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use super::*;

#[derive(Clone, Copy, Debug, Decode, Default, Display, Encode, PartialEq, Serialize)]
pub(crate) enum ColorType {
#[n(0)]
#[serde(rename = "cmyk")]
#[strum(serialize = "CMYK")]
Cmyk,
#[n(1)]
#[serde(rename = "grayscale")]
#[strum(serialize = "grayscale")]
Grayscale,
#[n(2)]
#[serde(rename = "indexed")]
#[strum(serialize = "indexed")]
Indexed,
#[default]
#[n(3)]
#[serde(rename = "rgb")]
#[strum(serialize = "RGB")]
Rgb,
}
13 changes: 13 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ pub enum Error {
backtrace: Option<Backtrace>,
path: RelativePath,
},
#[snafu(display("unsupported colorspace {colorspace:?} in image `{path}`"))]
ImageColorspace {
backtrace: Option<Backtrace>,
colorspace: zune_jpeg::zune_core::colorspace::ColorSpace,
path: DisplayPath,
},
#[snafu(display("failed to decode JPEG image `{path}`"))]
ImageDecodeJpeg {
backtrace: Option<Backtrace>,
Expand All @@ -254,6 +260,13 @@ pub enum Error {
path: DisplayPath,
source: ExifError,
},
#[snafu(display("unsupported chroma subsampling {horizontal}脳{vertical} in image `{path}`"))]
ImageSampleRatio {
backtrace: Option<Backtrace>,
horizontal: usize,
path: DisplayPath,
vertical: usize,
},
#[snafu(display("internal error, this may indicate a bug in filepack: {message}"))]
Internal {
backtrace: Option<Backtrace>,
Expand Down
Loading