changing an image 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?".

changing an image background color

Postby nightowl » 2008-01-12T09:38:45+00:00

Hello everyone! 8)

I try to learn imagemagick on my kubuntu dapper drake OS.

I tried to change the background color of an image i created first with:
convert -size 1400x1100 xc:black blackos.jpg

convert blackos.jpg -background white whitos.jpg

The trouble is that the color remains the same! And strangely if i have a look at the image with identify it says the background is white!

nobody@nowhere:~$identify -verbose blackos.jpg
blackos.jpg JPEG 1400x1100 PseudoClass 256c 6kb
Image: blackos.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Geometry: 1400x1100
Class: PseudoClass
Type: Grayscale
Endianess: Undefined
Colorspace: Gray
Channel depth:
Gray: 1-bits
Channel statistics:
Min: 0 (0)
Max: 0 (0)
Mean: 0 (0)
Standard deviation: 0 (0)
Colors: 256
1540000: ( 0, 0, 0) black
Rendering-intent: Undefined
Resolution: 72x72
Units: PixelsPerInch
Filesize: 6kb
Interlace: None
Background Color: white
Border Color: #DFDFDF
Matte Color: grey74
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
JPEG-Colorspace: 1
JPEG-Sampling-factors: 1x1
Signature: a11c1a7febfddd74d71a48977501c3a06f0db340b44795fd74fc825ab2f44d4b
Tainted: False
Version: ImageMagick 6.2.4 10/02/07 Q16

What can be wrong with that in fact?

Re: changing an image background color

Postby Bonzo » 2008-01-12T13:10:44+00:00

I can only assume the background is white but it is covered completly by blackos.jpg

What you are doing will not work, if you want to do that you will need to select the black and change it to white.

Code: Select all
convert blackos.jpg -fill white -opaque black whiteos.jpg
Posts: 2215
Joined: 2006-05-20T08:08:19+00:00
Location: Cambridge, England

Re: changing an image background color

Postby anthony » 2008-01-13T18:12:07+00:00

The -background SETTING is a image meta-data setting that usally does not effect the image itself. You need to modify the image, not modify the setting.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
User avatar
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: changing an image background color

Postby nightowl » 2008-01-15T04:25:14+00:00

Weel, thanks.
In fact i found out that to change the background color, you can use the "draw" command. That works very well for that purpose.

Return to Users

Who is online

Users browsing this forum: No registered users and 17 guests