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

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

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

Post 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??????
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

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

Post 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 ...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

I am not much of a PHP expert but try

\"$_POST['fill']\"
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

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

Post 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...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

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

Post by sriducati »

but how can i use color converter in place of color picker???
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo »

There are loads of color pickers here: http://www.hotscripts.com/search/all-sc ... lor+picker
Post Reply