Page 1 of 1

MagickNET and raw CMYK data

Posted: 2019-02-02T21:30:01-07:00
by pablobhz
Hello
Does MagickNET offers support for reading RAW CMYK Image data ?
ex: I have raw binary for one channel (cyan). Is there a way for MagickNet or ImageMagick to read it ?

Thanks in advance

Re: MagickNET and raw CMYK data

Posted: 2019-02-02T22:13:21-07:00
by snibgo
What do you mean by "raw"? Perhaps: no header, each pixel stored as a 8-bit or 16-bit number with no compression. See the "gray" format on http://www.imagemagick.org/script/formats.php

Re: MagickNET and raw CMYK data

Posted: 2019-02-02T22:16:57-07:00
by pablobhz
Thats what i meant, sorry for the bad information.
No header, just pixels. Each pixel stored as an 8-Bit number.

I tried to read a byte array on this format and it didn't worked =(
Can MagickNet interpret it or only ImageMagick command-line version ?

Re: MagickNET and raw CMYK data

Posted: 2019-02-02T23:02:50-07:00
by snibgo
Sorry, I don't use Magick.NET. But I expect it can read "gray:" format, in the same way as the command line.

Re: MagickNET and raw CMYK data

Posted: 2019-02-03T07:56:20-07:00
by dlemstra
You can use the PixelStorageSettings class for that. You can find an example in this recent issue: https://github.com/dlemstra/Magick.NET/issues/381

Re: MagickNET and raw CMYK data

Posted: 2019-02-03T21:10:26-07:00
by pablobhz
dlemstra wrote:
2019-02-03T07:56:20-07:00
You can use the PixelStorageSettings class for that. You can find an example in this recent issue: https://github.com/dlemstra/Magick.NET/issues/381
Thank you.
It worked flawlessly.

But how can i extract each channel from this PixelStorageSettings ?
I can't create individual objects from each array - it throws an error (The array length is 500396 but should be at least 2001580). Basically saying it can read only the entire array.

I've read the documentation on:
https://imagemagick.org/script/miff.php

But i couldn't understood. If i split my array lets say 4 by 4 bytes, the header+image data for that channel will be there ?
Ex: The cyan channel would be 0,4,8,12...and so on. Converting the PixelStorageSettings to ByteArray and extracting then (this way i mentioned) would work ?

Here's what i tried:

Code: Select all

var currSettings = new PixelStorageSettings(841, 595, StorageType.Char,PixelMapping.CMYK);
            MagickImage something = new MagickImage(currTiff, currSettings);
            using (var imgTest = new MagickImage(currTiff, currSettings))
            {
                var currPx = imgTest.GetPixels();
                IPixelCollection pixels = currPx;
                var pxVAl = pixels.GetValues();             
                byte[] targetArray = new byte[pxVAl.Length * 2];
                Buffer.BlockCopy(pxVAl, 0, targetArray, 0, pxVAl.Length * 2);
                byte[] anotherCyanChannel = new byte[targetArray.Length / 4];
                anotherCyanChannel = byteArrayBuilder(0, targetArray);
                MagickImage maybeitworks = new MagickImage(anotherCyanChannel);                
            }
Error: no decode for this format