Why not something like Image.LoadPreservePixelType method?
#3095
-
|
I'm struggling with finding a right way to just load the image in the original format and pixel type. I don't know if it exists and I am not seeing it. |
Beta Was this translation helpful? Give feedback.
Answered by
antonfirsov
Mar 26, 2026
Replies: 1 comment 8 replies
-
|
Use the non-generic version.
|
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

@DrkWzrd if you expect various pixel types to appear in your input, you can utilize
Image.Identifyto detect the pixel format before using it.Here is an example created by Claude Code. I tested it only on a tiny minority of the cases, so do not assume the code is correct, adapt it to your use-case and test it out extensively!
I think the library could help here more either by providing an API to enforce the original format or by making sure decoders are doing better job picking the right format (thought this could be insufficient if users need a guarantee, given the basic
Image.Loadoverload is not designed to provide it).