Page 1 of 1

changing an image background color

Posted: 2008-01-12T09:38:45-07:00
by nightowl
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

then:
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:
Gray:
Min: 0 (0)
Max: 0 (0)
Mean: 0 (0)
Standard deviation: 0 (0)
Colors: 256
Histogram:
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 http://www.imagemagick.org


What can be wrong with that in fact?

Re: changing an image background color

Posted: 2008-01-12T13:10:44-07:00
by Bonzo
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

Re: changing an image background color

Posted: 2008-01-13T18:12:07-07:00
by anthony
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.

Re: changing an image background color

Posted: 2008-01-15T04:25:14-07:00
by nightowl
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.