-
Notifications
You must be signed in to change notification settings - Fork 590
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
OpenEXR basic support #1475
OpenEXR basic support #1475
Conversation
Ah wait I branched off master lol. Should I have used branch |
They're mostly the same. |
@fintelia @HeroicKatora Are there any challenges with making the writer seekable? The reader already is. The user can always write to a byte vector first, if their writer is not seekable. As most writers are seekable anyways, this change would probably result in memory usage reduction. I can open a separate pull request for this change. |
@johannesvollmer please go ahead and make a PR against the |
In the exr library, I tried relaxing the requirements of the |
The more bounds we add to the interface the more restrictive it is. Could you go into more detail on why the library requires the reader to be |
The exr library reads individual pixel tiles one after another from a byte source. Multiple tiles can be decompressed in parallel. This should happen on the fly, without allocating all tiles at once. As a consequence, multiple threads have to pull the next pixel tile from the file, which apparently requires the byte source to be sendable between the threads. I have tried it again today and I think I got it working such that the reading from the file is only ever done in the main thread, and the blocks are sent to different threads for processing. Not sure yet whether it works correctly 100% of the time though, still doing some tests. |
…xr-initial-support
So, I have managed to not require sendable readers and writers. And I think it is possible to keep it this way in the future. I have released a new version of the exr library with the necessary changes. I'll try to get the seekable reader and writer PR done next. |
I got it compiling, but there are no tests that could ever fail for the exr codec. I'd like to ask for some suggestions concerning tests. My initial idea was to read and compare an HDR and EXR file of the same image, any objections? Are there any tests that should be done for every image type (and can also be done for high dynamic range f32 images)? I've had a look at the test image folders, but I must admit that I couldn't understand the Readme in the references folder. Should the exr codec have such a reference too? |
Also, is there no standardized way to obtain an image buffer from a decoder? I got stuck with the following code: let hdr: Vec<Rgb<f32>,> = image::codecs::hdr::HdrDecoder::new(
io::BufReader::new(fs::File::open(&reference_path).unwrap())
).unwrap().read_image_hdr().unwrap();
let exr_pixels: ImageBuffer<Rgba<f32>, Vec<f32>> = image::codecs::openexr::ExrDecoder::read(
io::BufReader::new(fs::File::open(&exr_path).unwrap())
).unwrap().read_f32_image_buffer().unwrap();
// TODO let hdr = ImageBuffer::from_raw(___)
assert_eq!(exr_pixels.dimensions(), hdr.____);
assert_eq!(exr_pixels.pixels(), hdr.____); |
Also, I couldn't find whether the image crate stores images upside down or upside up. Is positive y coordinate considered top of the image, or positive y considered the bottom of the image? The image buffer |
Got one tests working, but it feels like there should be an easier way of doing it |
|
…quested, add some convenience functions to read and write f32 buffers using exr
Using
|
Hey! I've finally had the time to press the So, from my perspective, we could merge this soon, as a minimal support. There's of course a lot of other things left to optimize, including the exr library itself. But for now, I estimate that 95% of uses cases are already covered, which is RGB images with F32 and F16 precision. I included an extensive list of limitations in the module documentation. Here's the contents:
Some of these limitations are simplifications, which may possibly never change: Only the first layer and largest mip map level. However, conversion between color models, meta data, and subsampling might be something we could add later. Note: The YCbCr conversion is specified in the OpenEXR standard, so it should be easy to implement, as it is fully defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice iteration overall. LGTM.
Regarding linear RGB vs. sRGB I hope we can solve it with the meta data PR and f32
in the next major release.
That would be great :) |
No wait.... the decoder should panic instead? Whoopsie :D Changed it to a panic. Would it make sense to unify this behaviour to be the same across decoding and encoding? |
…n the documentation
I'd say I'm ready to merge, but there seems to be a problem with the CI runner:
|
re-triggering the CI worked, now I'm ready to go :) |
Thanks for your support <3 |
Hey. as a newbie I may get it all wrong, but I'm trying this out with the image in the tests folder, and I called: let im = open("assets/cropping - uncropped original.exr").unwrap(); And got the following error:
I wonder why the format is FYI - this is what I have in my image = { git = "https://github.com/image-rs/image", rev="3197e3d964f5d214cbdec98206fbc895723e5c72" } |
Hi! Thanks for taking the time to post this. Next time, don't be afraid to open a full-blown issue and tag me in there :) Summary: While the exr file format can be decoded and encoded, the rest of the image library needs more time to properly implement f32 support everywhere. In detail: EXR files currently cannot be loaded as a |
Thanks for the clarification. Yeah - for now I'm playing around with the decoder directly. |
You're welcome. If you notice anything else, let me know :) |
Hi! Just experimented with adding OpenEXR support. Does not compile yet, work in progress.
Here's a list of things to do:
Read
/Write
(exrs only supports sendable stuff due to multi threading for now, might be able to relax this in exrs)next
branch)Current limitations:
Rgba32F
andRgba16F
are supportedI license past and future contributions under the dual MIT/Apache-2.0 license,
allowing licensees to chose either at their option.