Rust open png always as grayscale

I am aware of png - Rust
and the decoder example there.

Is there a way to tell Rust to always open the image as grayscale? I'm trying to avoid complicated modes like Indexed

I'm now convinced there's no obvious way to do this via png crate, and the simplest solution is to use the image crate: image::DynamicImage - Rust

I’m not aware of a way to force it to load as grayscale initially either. I’ve been using to_luma to get a GrayImage, which could be useful if you don’t want to introduce colours later:

1 Like

Your solution is definitely better, as mine provides a DynamicImage, whereas yours provides a GrayImage

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.