Skip to content

Commit

Permalink
Merge pull request #1716 from image-rs/exr-on-little-endian
Browse files Browse the repository at this point in the history
Restrict openexr to little endian platforms
  • Loading branch information
HeroicKatora committed May 28, 2022
2 parents cc8d74a + 1f03ece commit ed8337a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ rgb = { version = "0.8.25", optional = true }
mp4parse = { version = "0.12.0", optional = true }
dav1d = { version = "0.6.0", optional = true }
dcv-color-primitives = { version = "0.4.0", optional = true }
exr = { version = "1.4.2", optional = true }
color_quant = "1.1"

# These appear as an empty dependency on other platforms.
# See: <https://github.com/rust-lang/cargo/issues/1197#issuecomment-901794879>
[target.'cfg(target_endian = "little")'.dependencies]
exr = { version = "1.4.2", optional = true }

[dev-dependencies]
crc32fast = "1.2.0"
num-complex = "0.4"
Expand Down
2 changes: 0 additions & 2 deletions src/codecs/openexr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
//! - meta data is lost
//! - dwaa/dwab compressed images not supported yet by the exr library
//! - (chroma) subsampling not supported yet by the exr library

extern crate exr;
use exr::prelude::*;

use crate::error::{DecodingError, EncodingError, ImageFormatHint};
Expand Down
6 changes: 4 additions & 2 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ pub enum ImageOutputFormat {
/// An Image in TGA Format
Tga,

#[cfg(feature = "openexr")]
#[cfg(feature = "exr")]
#[cfg(target_endian = "little")]
/// An Image in OpenEXR Format
OpenExr,

Expand Down Expand Up @@ -327,7 +328,8 @@ impl From<ImageFormat> for ImageOutputFormat {
ImageFormat::Farbfeld => ImageOutputFormat::Farbfeld,
#[cfg(feature = "tga")]
ImageFormat::Tga => ImageOutputFormat::Tga,
#[cfg(feature = "openexr")]
#[cfg(feature = "exr")]
#[cfg(target_endian = "little")]
ImageFormat::OpenExr => ImageOutputFormat::OpenExr,
#[cfg(feature = "tiff")]
ImageFormat::Tiff => ImageOutputFormat::Tiff,
Expand Down
6 changes: 4 additions & 2 deletions src/io/free_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ pub(crate) fn load_decoder<R: BufRead + Seek, V: DecoderVisitor>(
image::ImageFormat::Ico => visitor.visit_decoder(ico::IcoDecoder::new(r)?),
#[cfg(feature = "hdr")]
image::ImageFormat::Hdr => visitor.visit_decoder(hdr::HdrAdapter::new(BufReader::new(r))?),
#[cfg(feature = "openexr")]
#[cfg(feature = "exr")]
#[cfg(target_endian = "little")]
image::ImageFormat::OpenExr => visitor.visit_decoder(openexr::OpenExrDecoder::new(r)?),
#[cfg(feature = "pnm")]
image::ImageFormat::Pnm => visitor.visit_decoder(pnm::PnmDecoder::new(r)?),
Expand Down Expand Up @@ -230,7 +231,8 @@ pub(crate) fn write_buffer_impl<W: std::io::Write + Seek>(
ImageOutputFormat::Tga => {
tga::TgaEncoder::new(buffered_write).write_image(buf, width, height, color)
}
#[cfg(feature = "openexr")]
#[cfg(feature = "exr")]
#[cfg(target_endian = "little")]
ImageOutputFormat::OpenExr => {
openexr::OpenExrEncoder::new(buffered_write).write_image(buf, width, height, color)
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ pub mod codecs {
pub mod ico;
#[cfg(feature = "jpeg")]
pub mod jpeg;
#[cfg(feature = "openexr")]
#[cfg(feature = "exr")]
#[cfg(target_endian = "little")]
pub mod openexr;
#[cfg(feature = "png")]
pub mod png;
Expand Down

0 comments on commit ed8337a

Please sign in to comment.