Colour overlay

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
rhousham

Colour overlay

Post by rhousham »

Hi I am trying to make a system where by users can select a background colour and a foreground colour and a image. The system will then take the image that you have selected and use the foreground colour to colour it and the background colour behind it. I can do this but I want to keep the anti alias in order to make the images look smooth here is what I have so far



/usr/local/bin/convert -size 60x60 plasma:fractal -virtual-pixel edge -blur 0x5
-shade 140x45 -normalize
-size 1x100 xc:black -size 9x100 gradient:
+append '. $image_location_file;

The image_location_file is the place of the file. I don't quite know what this line does!?.

/usr/local/bin/convert -size 10x100 gradient:"'.$background_colour.'"-"'.$shape_colour.'" '.$gradient;

This line creates a gradient in a new file gradient

/usr/local/bin/convert '.$image_location_file.' '.$gradient.' -fx \'v.p{0,u*v.h}\' '.$image_location_file2;

This then applies the gradient
$cmd = '/usr/local/bin/convert '.$image_location_file2.' -matte -fill none -draw \'matte 0,0 floodfill\' '.$image_location_file2;

This removes the bg

$cmd = 'convert -size 60x60 xc:"'.$background_colour.'" -draw "image over 0,0 0,0
This puts the file on the background.

I thought this would work but I've been going round and round on this trying different methods.
If anyone has any ideas.
Thanks for any help.
rhousham

Re: Colour overlay

Post by rhousham »

No worries guys I sorted it a quick chat about anti alias and my eyes were opened!.
any who for those who have come to this post here is the solution

$cmd = '/usr/local/bin/convert -size 60x60 plasma:fractal -virtual-pixel edge -blur 0x5
-shade 140x45 -normalize
-size 1x100 xc:black -size 9x100 gradient:
+append '. $image_location_file;
//echo $cmd."<br />";
//exec($cmd);
$cmd = ' /usr/local/bin/convert -size 10x100 gradient:"'.$shape_colour.'"-"'.$shape_colour.'FF" '.$gradient;
echo $cmd."<br />";
exec($cmd);
$cmd = '/usr/local/bin/convert '.$image_location_file.' '.$gradient.' -fx \'v.p{0,u*v.h}\' '.$image_location_file2;
echo $cmd."<br />";
exec($cmd);



$cmd = 'convert -size 60x60 xc:"'.$background_colour.'" -draw "image over 0,0 0,0 \''.$image_location_file2.'\'" '. $image_location_file3;
echo $cmd."<br />";
exec($cmd);

Onwards MacDuff!
Post Reply