gradients going wrong

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?".
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: gradients going wrong

Post by davidb2002 »

Im viewing the image in firefox, safari and internet explorer. All show black bars running through it (internet explorer shows slightly lighter black bars).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: gradients going wrong

Post by fmw42 »

davidb2002 wrote:Im viewing the image in firefox, safari and internet explorer. All show black bars running through it (internet explorer shows slightly lighter black bars).
I am using Safari 3.1.2 Mac OSX 10.4.11 Tiger and I don't see any black bars. But in Firefox, I do see them. Let me analyze further, but try the other test I suggested.

I looked at the verbose info of your image and mine. I don't see any irregularities on quick examination, except your image is 8-bit and mine is 16-bit. Are you running Q8 IM? I am on Q16. In principle it should not matter. I will look some further.
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: gradients going wrong

Post by davidb2002 »

First tell me if this works:
convert -size 100x100 xc:white xc:gray40 xc:black -combine test_color4.png
Image
no, it gives me a blue colour:

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

Re: gradients going wrong

Post by fmw42 »

davidb2002 wrote:
First tell me if this works:
convert -size 100x100 xc:white xc:gray40 xc:black -combine test_color4.png
Image
no, it gives me a blue colour:

Image

Very strange. Try putting "" quotes around "white", "gray40" and "black"

Also the verbose info of your orange with black stripes image also shows:
Colormap: 1
0: (255,102, 0) #FF6600 rgb(255,102,0)


This is not in my image. This may be what is causing your black stripes. I am not sure how to remove this right now, but will look into it. Perhaps someone else can answer. Perhaps -strip or something. I need to look further into this.

try without the -depth 8
convert -size 100x100 xc:"rgb(255,102,0)" test_color5.png

and also try

convert -size 100x100 xc:"rgb(100%,40%,0%)" test_color6.png

and then with repeat both with -depth 8 (presuming you are on Q16)

Also you are getting a pseudoclass type image. Try repeating again but adding -type TrueColor on both these cases also. Hopefully, one of these methods may work out.
Last edited by fmw42 on 2008-10-07T13:19:10-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: gradients going wrong

Post by fmw42 »

Also the verbose info of your orange with black stripes image also shows:
Colormap: 1
0: (255,102, 0) #FF6600 rgb(255,102,0)
With regard to this issue, I simply tried to copy your image

convert text_color2.png text_color2b.png
convert: Invalid colormap index `text_color2.png'.

So there is an error in the generation of this image that IM does not like regarding the colormap (that probably should not be there).

Again, try something like:

convert -size 100x100 xc:"rgb(255,102,0)" -type TrueColor test_color5a.png

and also try

convert -size 100x100 xc:"rgb(100%,40%,0%)" -type TrueColor test_color6a.png

You can also try the above with -depth 8, if you are on Q16 and would prefer a smaller size image.

convert -size 100x100 xc:"rgb(255,102,0)" -depth 8 -type TrueColor test_color5b.png

and also try

convert -size 100x100 xc:"rgb(100%,40%,0%)" -depth 8 -type TrueColor test_color6b.png


So 4 tests. Please report back on your results.

Also please copy and paste your command that you used to generate the blue image. Perhaps there is a typo that is causing such a radical change.
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: gradients going wrong

Post by davidb2002 »

Just want to say thanks so far for being so helpful. All 4 tests come back with the correct shade of orange:

/usr/local/bin/convert -size 100x100 xc:"rgb(255,102,0)" -type TrueColor test_color5a.png
Image

/usr/local/bin/convert -size 100x100 xc:"rgb(100%,40%,0%)" -type TrueColor test_color6a.png
Image

/usr/local/bin/convert -size 100x100 xc:"rgb(255,102,0)" -depth 8 -type TrueColor test_color5b.png
Image

/usr/local/bin/convert -size 100x100 xc:"rgb(100%,40%,0%)" -depth 8 -type TrueColor test_color6b.png
Image
davidb2002
Posts: 37
Joined: 2008-09-01T08:31:26-07:00

Re: gradients going wrong

Post by davidb2002 »

I have managed to get it to work using some PHP trickery to manipulate the string IM returns:
$cmd = IMAGEMAGIKDIR.' -size 1x1 xc:"#FF6600" -depth 8 txt:';
$rgb = exec($cmd);

# SPLIT THE STRING TO GET THE RGB VALUES RETURNED
$start = strpos($rgb,'(');
$end = strpos($rgb,')');
$length = $end-$start+1;
$rgb = substr($rgb,$start,$length);
$rgb = str_replace(' ','',$rgb);

$cmd = IMAGEMAGIKDIR.' -size 10x100 xc:"rgb'.$rgb.'" -depth 8 -type TrueColor myfile.png;
exec($cmd);
Thanks for the help all the way through this. I basically went through the entire topic again and picked out what worked and used my php skills to use bits and pieces.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: gradients going wrong

Post by fmw42 »

davidb2002 wrote:I have managed to get it to work using some PHP trickery to manipulate the string IM returns:
$cmd = IMAGEMAGIKDIR.' -size 1x1 xc:"#FF6600" -depth 8 txt:';
$rgb = exec($cmd);

# SPLIT THE STRING TO GET THE RGB VALUES RETURNED
$start = strpos($rgb,'(');
$end = strpos($rgb,')');
$length = $end-$start+1;
$rgb = substr($rgb,$start,$length);
$rgb = str_replace(' ','',$rgb);

$cmd = IMAGEMAGIKDIR.' -size 10x100 xc:"rgb'.$rgb.'" -depth 8 -type TrueColor myfile.png;
exec($cmd);
Thanks for the help all the way through this. I basically went through the entire topic again and picked out what worked and used my php skills to use bits and pieces.
Glad to hear the good news. And happy to have been able to help.
Post Reply