Skip to content

Commit ca8fa52

Browse files
authored
Merge pull request #2644 from image-rs/gif-0.14
Bump Gif to 0.14, introducing XMP and ICC
2 parents c7f68be + 053220a commit ca8fa52

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ num-traits = { version = "0.2.0" }
4444
color_quant = { version = "1.1", optional = true }
4545
dav1d = { version = "0.10.3", optional = true }
4646
exr = { version = "1.74.0", default-features = false, optional = true }
47-
gif = { version = "0.13.1", optional = true }
47+
gif = { version = "0.14.0", optional = true }
4848
image-webp = { version = "0.2.0", optional = true }
4949
mp4parse = { version = "0.17.0", optional = true }
5050
png = { version = "0.18.0", optional = true }

src/codecs/gif.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ impl<R: BufRead + Seek> ImageDecoder for GifDecoder<R> {
214214
Ok(())
215215
}
216216

217+
fn icc_profile(&mut self) -> ImageResult<Option<Vec<u8>>> {
218+
// Similar to XMP metadata
219+
Ok(self.reader.icc_profile().map(Vec::from))
220+
}
221+
222+
fn xmp_metadata(&mut self) -> ImageResult<Option<Vec<u8>>> {
223+
// XMP metadata must be part of the header which is read with `read_info`.
224+
Ok(self.reader.xmp_metadata().map(Vec::from))
225+
}
226+
217227
fn read_image_boxed(self: Box<Self>, buf: &mut [u8]) -> ImageResult<()> {
218228
(*self).read_image(buf)
219229
}
@@ -634,20 +644,16 @@ impl ImageError {
634644
fn from_decoding(err: gif::DecodingError) -> ImageError {
635645
use gif::DecodingError::*;
636646
match err {
637-
err @ Format(_) => {
638-
ImageError::Decoding(DecodingError::new(ImageFormat::Gif.into(), err))
639-
}
640647
Io(io_err) => ImageError::IoError(io_err),
648+
other => ImageError::Decoding(DecodingError::new(ImageFormat::Gif.into(), other)),
641649
}
642650
}
643651

644652
fn from_encoding(err: gif::EncodingError) -> ImageError {
645653
use gif::EncodingError::*;
646654
match err {
647-
err @ Format(_) => {
648-
ImageError::Encoding(EncodingError::new(ImageFormat::Gif.into(), err))
649-
}
650655
Io(io_err) => ImageError::IoError(io_err),
656+
other => ImageError::Encoding(EncodingError::new(ImageFormat::Gif.into(), other)),
651657
}
652658
}
653659
}

0 commit comments

Comments
 (0)