image icon indicating copy to clipboard operation
image copied to clipboard

Support for opening raw image formats(cr2, nef etc.)

Open qarmin opened this issue 4 years ago • 9 comments

Frequently requested feature in my app is to be able to find similar images for raw formats like nef or cr2.

To be able to do this I use img_hash crate which uses this library to hash content of each supported image(jpg, png, tiff).

Since I don't know much about internals this formats, I don't know if it is possible to implement them.

I can open such images in default image viewer(Eye of Gnome) so I suspect that image can be used in same way as jpg or png are handled.

qarmin avatar Dec 02 '21 14:12 qarmin

Do you have a clearer list of formats, maybe even statistics of how often they are encountered? In terms of prioritization or developers that know one of them and seeing the demand represented and rewarded it can be valuable.

We're pretty open to accepting any new sort of format but the contributor bandwidth for writing and maintaining the same quantity of decoders as EoG honestly does not seem to be there (yet?).

197g avatar Dec 02 '21 18:12 197g

According to Wikipedia, cr2 files are valid TIFF files. They may actually just work with our current TIFF decoder

fintelia avatar Dec 02 '21 20:12 fintelia

Raw files are difficult, as they do not obey any Standard, and change often. The Rust crate rawloader supports a lot of raw formats and has the goal to keep up with the changes

Would you consider using both crates in parallel?

johannesvollmer avatar Dec 27 '21 08:12 johannesvollmer

It looks like this library is that what I'm looking for, but I can't find example how could I decode image inside rawloader and pass it to image-rs(img_hash library which I use, needs image struct from image-rs crate)

qarmin avatar Dec 31 '21 13:12 qarmin

Raw is difficult because it's basically just a sensor dump. There's a large amount of processing required to obtain the RGBA pixels, such as demosaicing. The rawloader library is just for loading the image, as I understand it. Maybe a different crate also provided the conversion from raw to RGB, or maybe this exact conversion would be a nice feature for image-rs

johannesvollmer avatar Dec 31 '21 17:12 johannesvollmer

I scanned the dependents of the rawloader create and found this crate from the same author: https://crates.io/crates/imagepipe

Promising?

johannesvollmer avatar Jan 01 '22 14:01 johannesvollmer

I already added support for raw files in https://github.com/qarmin/czkawka/commit/0f0e7a338fe5459a90f3e9c6eea024599961df1c

This code showed me how to convert raw file to DynamicImage(use both imagepipe and rawloader) https://github.com/Kl4rry/simp/blob/09c732097546ef77d6e1f1fce81cac40ddaddacf/src/image_io/load.rs#L124-L159 (I have a problem with hashing dark raw images, but probably with normal images problem also occurs )

qarmin avatar Jan 01 '22 15:01 qarmin

FYI there's also https://github.com/paolobarbolini/libraw-rs/tree/master/libraw. It's passively maintained in the sense that I won't add bindings to the remaining libraw APIs, but I use it myself and try to keep it alive and updated

paolobarbolini avatar Jan 01 '22 15:01 paolobarbolini

Rawloader seems to be abandoned by library author(last author activity > 1 year ago). Quite sad, since it was probably the only full rust raw loader solution, but quite slow(at least converting decoded files to image-rs DynamicImage format)

qarmin avatar Nov 12 '23 20:11 qarmin