Page 1 of 1

hexa color codes not accepting in image magickk..please help

Posted: 2011-11-28T11:38:15-07:00
by sriducati
Hello Webmasters

i have desghned a user input form where user can choose one of the colors from color picker ,i have used imagemagick code in an out put page where it display a colored text(choosen by user).... It is a very simple script which works fine when tyhe user enters color name but does not work when we enter color hexa decimal..... i got to know when we use hexa decimal we need to enter in this way " '#00ff345' " ...i tried same thing which worked fine again but what sall i do when using color picker ??? it enter #00ff345 ...it will not enter ' ' ....without this quote it does not accept color codes... how do i fix it??????

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-28T12:06:37-07:00
by Bonzo
What code are you using; php?

If so I assume you have #00ff345 in a variable something like $colour_varible='#00ff345'; so you could:

Code: Select all

$colour_varible='#00ff345';
$variable = "'$colour_varible'";
Then use $variable in your code.

I would have thought it was OK to have the colour name between ' ' as well but you would need to test that.

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-28T13:33:58-07:00
by fmw42
If you use hex or rgb values in IM, you need to reference them with quotes. But if you use variables to hold them then you need to use double quotes so that the variable can be parsed.

convert -size 100x100 xc:"#FF0000" ....

or

color="#FF0000"
convert -size 100x100 xc:"$color" ....

see
http://www.imagemagick.org/script/color.php

In PHP you need to be careful about nested quotes also.

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-28T14:33:22-07:00
by sriducati
thanks a lot for your reply guyz ..... here is the code iam using...

Code: Select all

<?php
if (isset($_POST['fill']) && isset($_POST['label']) && isset($_POST['pointsize'])) {
$cmd =" -background NONE -pointsize ". $_POST['pointsize'] ." -font Times-Roman -fill ". $_POST['fill'] . " ".
" -strokewidth 1 -stroke black label:\" ".$_POST['label'] . "\" ";

exec("convert $cmd 1.png");
echo "<img src='1.png'>";
}
else{
echo "ERROR";
}
?>

we can get output from any color picker in the form of #ff001236 ... but i need the out put in the form of '#ff001236' ...so that it can be accepted by imagemagick.... any idea guyzzzzz????
'fill' is the color variable i have used in input form ...

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-28T14:48:29-07:00
by fmw42
I am not much of a PHP expert but try

\"$_POST['fill']\"

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-30T03:26:36-07:00
by sriducati
any idea on how can we fix this problem.. is it possible to use color picker in this case (which outputs only hexa code)... if yes which is the color picker we can try ...i tried js color picker ....but no luck... please help me...

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-11-30T19:13:58-07:00
by fmw42
Have you seen the Color Convert (PHP app) that is near the top of http://www.imagemagick.org/script/color.php. Created by Bonzo and myself

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-12-01T08:11:56-07:00
by sriducati
but how can i use color converter in place of color picker???

Re: hexa color codes not accepting in image magickk..please

Posted: 2011-12-01T13:31:21-07:00
by Bonzo
There are loads of color pickers here: http://www.hotscripts.com/search/all-sc ... lor+picker