text color background color

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
appollosputnik
Posts: 3
Joined: 2013-08-18T00:30:46-07:00
Authentication code: 6789

text color background color

Post by appollosputnik »

I want to extract text color and background color from a PNG file. PLease help me how can I do it. Thanks Sujan
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: text color background color

Post by Bonzo »

You need to add more information: Platform, IM version and programming language you want to use as well as an example..
appollosputnik
Posts: 3
Joined: 2013-08-18T00:30:46-07:00
Authentication code: 6789

Re: text color background color

Post by appollosputnik »

I am trying to get the image's backgroun color using python - pythonMagick. How can I get the RGB values of the current background.

Code: Select all

im2 = PythonMagick.Image('myimage.png')
bgColor = im2.backgroundColor().to_std_string()
print bgColor
appollosputnik
Posts: 3
Joined: 2013-08-18T00:30:46-07:00
Authentication code: 6789

Re: text color background color

Post by appollosputnik »

I am working in Linux Ubuntu with python 2.7.5 and pythonMagick. Please help me how can I get the background color of my image.?? My image is a converted PDF to PNG. It has text and background color. Generally the background color is white but sometimes the background color is other (green, blue, red etc)...How can I get the background color.

I actually want to calculated the contrast of my PDF file. So trying to convert it into an image then extract the background color. please help. Thanks Sujan

Code: Select all

        im2 = PythonMagick.Image('myimage.png')
        bgColor = im2.backgroundColor
        red = bgColor.redQuantum()
        green = bgColor.greenQuantum()
        blue = bgColor.blueQuantum()
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: text color background color

Post by snibgo »

It would help if you provided an example image.

What distinguishes text from background? Are they solid colours, with or without antialiasing? Pehaps histogram would help, giving the two most common colours.
snibgo's IM pages: im.snibgo.com
Post Reply