Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional serde feature for image::ImageFormat #2374

Merged
merged 1 commit into from
Nov 1, 2024
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ rgb = { version = "0.8.48", default-features = false, optional = true }
tiff = { version = "0.9.0", optional = true }
zune-core = { version = "0.4.12", default-features = false, optional = true }
zune-jpeg = { version = "0.4.13", optional = true }
serde = { version = "1.0.214", optional = true, features = ["derive"] }

[dev-dependencies]
crc32fast = "1.2.0"
Expand Down Expand Up @@ -92,6 +93,7 @@ nasm = ["ravif?/asm"] # Enables use of nasm by rav1e (requires nasm to be instal
color_quant = ["dep:color_quant"] # Enables color quantization
avif-native = ["dep:mp4parse", "dep:dcv-color-primitives", "dep:dav1d"] # Enable native dependency libdav1d
benchmarks = [] # Build some inline benchmarks. Useful only during development (requires nightly Rust)
serde = ["dep:serde"]

[[bench]]
path = "benches/decode.rs"
Expand Down
4 changes: 4 additions & 0 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use std::mem::size_of;
use std::ops::{Deref, DerefMut};
use std::path::Path;

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::color::{ColorType, ExtendedColorType};
use crate::error::{
ImageError, ImageFormatHint, ImageResult, LimitError, LimitErrorKind, ParameterError,
Expand All @@ -20,6 +23,7 @@ use crate::animation::Frames;
/// An enumeration of supported image formats.
/// Not all formats support both encoding and decoding.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub enum ImageFormat {
/// An Image in PNG Format
Expand Down
Loading