Hello,
I'm trying to do some metadata editing / resizing to images, and am having trouble retaining the colorspace / colorprofile / colortype of images when the original image was an RGB that's mostly grey. They get automatically changed to greyscale.
Specifically, the big problem is with jpegs, because they get converted at some point after opening the file, before I can find out what the original colorspace was.
This is what is happening - it's fairly strange - I open a jpg which is an RGB image that is mostly full of grey pixels, and put a breakpoint in immediately afterwards.
using (var image = new MagickImage(imageFilePath))
then my breakpoint sits on the opening "{" straight after.
If I examine the variable "image" at this point, it tells me its colorspace is RGB.
If I don't step forwards, but examine the variable "image" for a second time, the colorspace becomes Greyscale.
I checked the actual file, and when it changes in memory, it's not because it's changed on disk.
So:
a) What is changing it, and
b) how can I stop it?
It's important for me to retain the original colorspace of a file, whether it was RGB or greyscale or whatever. I must not change the colours, even if the result is more "correct".
This specific behaviour only happens with .jpeg files too.
If I try the same thing with a .tiff which was an RGB image that is mostly grey, the colorspace does not immediately change, so I can capture the original colorspace of a file when I open it, then re-apply it to a file after processing - so if it was automatically converted to greyscale, I can change it back.
I'm trying to do some metadata editing / resizing to images, and am having trouble retaining the colorspace / colorprofile / colortype of images when the original image was an RGB that's mostly grey. They get automatically changed to greyscale.
Specifically, the big problem is with jpegs, because they get converted at some point after opening the file, before I can find out what the original colorspace was.
This is what is happening - it's fairly strange - I open a jpg which is an RGB image that is mostly full of grey pixels, and put a breakpoint in immediately afterwards.
using (var image = new MagickImage(imageFilePath))
then my breakpoint sits on the opening "{" straight after.
If I examine the variable "image" at this point, it tells me its colorspace is RGB.
If I don't step forwards, but examine the variable "image" for a second time, the colorspace becomes Greyscale.
I checked the actual file, and when it changes in memory, it's not because it's changed on disk.
So:
a) What is changing it, and
b) how can I stop it?
It's important for me to retain the original colorspace of a file, whether it was RGB or greyscale or whatever. I must not change the colours, even if the result is more "correct".
This specific behaviour only happens with .jpeg files too.
If I try the same thing with a .tiff which was an RGB image that is mostly grey, the colorspace does not immediately change, so I can capture the original colorspace of a file when I open it, then re-apply it to a file after processing - so if it was automatically converted to greyscale, I can change it back.