Black and white with magick++

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?".
Post Reply
imagetester

Black and white with magick++

Post by imagetester »

Hi, well i have a small problem: I need to transform ANY image to black and white AND I want each pixel to take a (0,0,0) or a (255,255,255) value !!!
The normal monochrome image ( 1 bit for each pixel ) is disturbing me (can't use it in my database !)
So is there any way that i can achieve that ?!
PS: I'm using C++ with Magick++.


Thanks in advance,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Black and white with magick++

Post by fmw42 »

If you are starting with grayscale, then use -threshold to convert to b/w, then -depth 8. If you are starting with 1-bit and want 8-bit, try -depth 8 to force it to 0-255 range, b/w only 0 or 255.

Sorry I do not know the C++ / Magick++ commands
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Black and white with magick++

Post by anthony »

Basically you will need to get the output image format coder to generate a 8 bit per color image. There are ways to do it, but you never specified the image file format you are generating for storing in your database (presumably by a API 'blob').
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply