Gradient Effect

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?".
geeta

Gradient Effect

Post by geeta »

Hello,
I tried this command
convert -size 320x100 xc:lightblue -font Candice -pointsize 72 \
-tile gradient: -annotate +28+68 'Anthony' \
font_gradient.jpg
which works perfectly.
Now I want the gradient to be in diffent angle, I have tried the following command which is given under canvas creation.
convert -size 142x142 gradient: -rotate -45 \
-gravity center -crop 100x100+0+0 +repage \
gradient_diagonal.jpg
This command is userful only for creating canvas, I tried in manier ways to make it work for Text.
Can any one help me out to define angle for gradient effect.
Also I would like to know how can I give fisheye,expanding text effect.

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

Re: Gradient Effect

Post by fmw42 »

One way is as follows:

First make an extra large gradient image at the angle you want and crop out the middle section to the size of your text. Then use that image with -tile as follows:

convert -size 512x512 gradient: -rotate -45 \
-gravity center -crop 320x100+0+0 grad45.png

(alternate for 45degrees only: convert -size 320x100 xc: -fx "(i/w + j/h)/2" grad45.png)

convert -size 320x100 xc:lightblue -font Candice -pointsize 72 \
-tile grad45.png -annotate +28+68 'Anthony' \
font_gradient2.jpg

With regard to the fisheye font shape, I have just uploaded a texteffect bash script (for Unix/Linux or Window with cygwin) that has something like that as an effect and also allows you to specify a tile image. See

http://www.fmwconcepts.com/imagemagick/index.html
geeta

Re: Gradient Effect

Post by geeta »

Hello fred,
Thanks for prompt reply. The text effect that you have uploaded are fantastic, I have downloaded your script but I don;t know how to use it. I mean should I save the file as .sh file on server and then execute the command that you have specified on site?
Or can you just guide me to write ImageMagick command for
Outline Wedge-Left Text
Outline Concave Text
Outline Pinch Text
Outline Bulge Text

If all works for me, then that would be a great help :)
ImageMagick is a real great tool. I am becoming fan of it.
Thanks a Lot.
Geeta
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Gradient Effect

Post by Bonzo »

I have just tried a couple of examples at random using php and they nearly work :shock:
Point size problem ?
line 242 = [ $pointsizetestA -eq 1 ] && errMsg "--- POINTSIZE=$pointsize MUST BE A POSITIVE INTEGER ---"

The way I do it:
1/ Rename the script from texteffect to texteffect.sh
2/ Upload to the server and CHMOD to 755
3/ Put the full path to the script in your code
4/ Make sure you have the path to the font set
5/ Code sample below - with error reporting

Code: Select all

<?php
    // Run the script
    exec("/FULL/PATH/TO/texteffect.sh -t \"SOME GLOW TEXT\" -s glow -e normal -f verdana.ttf -p 48 -c skyblue -b white -o skyblue -l 1 -g blue fred.png 2>&1", $array); 
    //Display any errors
    echo "<br>".print_r($array)."<br>"; 
    echo "</pre>";
    ?> 
	
	<img src="fred.png">
	
	<?php
    // Run the script
    exec("/FULL/PATH/TO/texteffect.sh -t \"SOME ARCTOP TEXT\" -s plain -e arc-top -a 180 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink fred1.png 2>&1", $array); 
    //Display any errors
    echo "<br>".print_r($array)."<br>"; 
    echo "</pre>";
    ?> 
	
	<img src="fred1.png">
Results:
http://www.rubble.info/TESTS/fred.png
Error reporting - Array ( [0] => (standard_in) 1: parse error [1] => /TESTS/texteffect.sh: line 242: [: -eq: unary operator expected )
1

http://www.rubble.info/TESTS/fred1.png
Array ( [0] => (standard_in) 1: parse error [1] => /TESTS/texteffect.sh: line 242: [: -eq: unary operator expected [2] => (standard_in) 1: parse error [3] => /TESTS/texteffect.sh: line 242: [: -eq: unary operator expected )
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient Effect

Post by fmw42 »

Replies to two issues:

1. you can leave the .sh off and just use:

texteffect ...options as shown in examples... outputfile

use -t "some text" -s outline -e wedge-left etc for example

or you can add the .sh and use:

texteffect.sh ...options as shown in examples... outputfile



2. thanks for the notice on the error. I had found that yesterday (typo error in editing it) and am updating the script later today after I add another style for gradient. So look for an update sometime later today.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Gradient Effect

Post by Bonzo »

It must be something to do with my server setup as I can not use a file without an extension; so have to add the .sh to the end.

Some interesting effects Fred.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient Effect

Post by fmw42 »

I just uploaded a new version. I fixed several places where there was a typo that caused the errors in trapping on parameters. I hope I caught them all. Let me know if there are any further errors.

On my Mac, I don't seem to need the extension. But I have no experience on other systems.

I hope I can improve the concave and convex effects so that there is less distortion on the top and bottom versions. But I don't know when I will get back to that.

Fred
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Gradient Effect

Post by Bonzo »

Just tried your updated script and no errors now but the effects are not the quite the same as yours:
http://www.rubble.info/TESTS/fred.png
http://www.rubble.info/TESTS/fred1.png

Although this one looks the same:
http://www.rubble.info/TESTS/fred2.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient Effect

Post by fmw42 »

Thanks for your feedback.

I have uploaded a new version today of my script texteffect, 4/6/08, that fixes the problems that have been reported. I appreciate your feedback.

Fred
geeta

Re: Gradient Effect

Post by geeta »

Hello,
I have tried the following command which is integration of shadow+stroke+gradient
/usr/local/bin/convert -density 90 -fill black -size 212x80 xc:none -font "Arial-Regular" -pointsize 45 -tile gradient:orangered -annotate +28+63 "123456" -stroke darkmagenta -strokewidth 2.3 -annotate +20+50 123456 -stroke yellow -strokewidth 1.05 -annotate +20+50 123456 -blur 0x8 -annotate +20+50 123456 -matte -background none -wave -9x120 \( +clone -background darkmagenta -shadow 80x4+5-7 \) +swap -background white -flatten -trim +repage /home/customav/public_html/beta/images/temp_images/text_img_47fb39d179e87.jpg

you can see the result image here:
http://beta.customavenue.com/images/tex ... 179e87.jpg

Now the problem I am facing here is
You can see the black shadow below the actual 123456. Actual shadow color is darkmagenta that could be seen aroung yellow 123456 but that additional shadow is giving me trouble. Can someone tell me for what that shadow is comming?
One more thing fred,
As you have given me the site for text effect that reallyworks nicely. But what I want is clubbing the various effect. I am doing some R&D on that so that the texteffect applieswould be more.

Thanks for your help,
Geeta
P.S: That shadow is comming only when I added gradient effect in addition. Rest all effects are working perfectly.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient Effect

Post by fmw42 »

I am not sure which shadow is the one you want and which is the one you want to remove. Can you clarify that?

With regard to you questions about my texteffect script, I am not sure I understand what mean by "clubbing". Again can you clarify?
geeta

Re: Gradient Effect

Post by geeta »

Hello Fred,
The black shadow which you can see at down
http://beta.customavenue.com/images/tex ... 179e87.jpg

Actually I tried with texteffect.sh as you suggested but I am not able to have all the effects together i.e. as you can see in above image is having shdaow+gradient+stroke+wave effects working together in which other effects are working fine i.e shdaow+stroke+wave works fine but when I add gradient effect it starts giving problem of additional black shadow.

I tried to do the above effects with texteffect.sh i.e all effects together i.e
fisheye + glow +stroke+gradient.
But it did not work.Single effect is working fine as you have given on site.
Can you guide me how can get all the effects together.

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

Re: Gradient Effect

Post by fmw42 »

Sorry, but you can use only ONE style (-s option) at a time in my script! You cannot combine multiple styles (-s option) in the same command line. For example, you cannot combine glow and shadow or glow and gradient. You can use only one -s option for style and one -e option for effect. Some styles however allow outline as well, such a glow, but that is controlled by the -o option and the -l option. I will make this clearer in my documentation. Basically you can only use one of each of the arguments listed.

To do more styles than one at a time, you will need to build your own custom command line or somehow create two images each with different styles and overlay them together. But I cannot say if that will work well.

I have no fisheye. The closest is convex or bulge.
geeta

Re: Gradient Effect

Post by geeta »

ohhh... hummm I have done some r&d the following command do various things at time

/usr/local/bin/convert -density 90 -fill black -size 212x80 xc:none -font "Arial-Regular" -pointsize 45 -tile gradient:orangered -annotate +28+63 "123456" -stroke darkmagenta -strokewidth 2.3 -annotate +20+50 123456 -stroke yellow -strokewidth 1.05 -annotate +20+50 123456 -blur 0x8 -annotate +20+50 123456 -matte -background none -wave -9x120 \( +clone -background darkmagenta -shadow 80x4+5-7 \) +swap -background white -flatten -trim +repage /home/customav/public_html/beta/images/temp_images/text_img_47fb39d179e87.jpg

Gives you stroke+shadow+gradient+wave

The only problem here is when I add gradient effect the shadow effect does not work properly.

http://beta.customavenue.com/images/tex ... 179e87.jpg
Glow with all effects works finely.
And thanks for the gradient effect help it really worked nicely for me. :)
If you could help me to getting rid of the black shadow from
http://beta.customavenue.com/images/tex ... 179e87.jpg
that would be a great help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gradient Effect

Post by fmw42 »

Try this:

convert -density 90 -size 212x80 xc:none -font Arial-Regular -pointsize 45 \
-stroke darkmagenta -strokewidth 2.3 -annotate +20+50 "123456" \
-tile gradient:orangered -annotate +20+50 "123456" \
-stroke yellow -strokewidth 1.05 -annotate +20+50 "123456" \
\( +clone -background darkmagenta -shadow 80x4+5-7 \) \
-background white +swap -flatten -wave -9x120 +repage \
tmp.png


you have an extra, unneeded

-annotate +20+50 "123456" -matte -background none

and your wave should be at the end and be sure to put your text in quotes
Post Reply