How to check image color or back and white

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
BenjaminKim
Posts: 11
Joined: 2019-05-03T12:14:07-07:00
Authentication code: 1152

Re: How to check image color or back and white

Post by BenjaminKim »

Update:

I was finally able to work out exactly what I needed. Many thanks to those who helped and helped guide me to the solution I needed.

In running tests across many, many thousands of PDFs, I kept getting inconsistent results for what I was trying to accomplish. This was no fault of ImageMagick - it was due to the way two different engines were rasterizing the original PDF. It's a long story.

Once I got past that, I was trying to leverage HSB - but it still wasn't producing expected results. I kept digging, and ultimately found that .NET's "Color.GetBrightness()" method uses HSL, not HSB. https://docs.microsoft.com/en-us/dotnet ... mework-4.8 Of course, I now see that it says at the very top that is uses "HSL", but I actually had verified this via the old fashioned approach - getting RGB values and running it through the HSL formula.

And as I was ultimately comparing against images generated in .NET, it all came together.

All said - this is what I've used once the PDF has been rasterized. I used quantum values to be a bit more precise.

magick sample.tif -colorspace HSL -channel L -separate -range-threshold 43908,43908,65530,65530 -negate -compress group4 mask.tif
Post Reply