Page 1 of 1

Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-17T00:25:15-07:00
by whugemann
I haven't worked with transpareny a lot so far, so this question might have a simple answer. I would like to create a circular gragient from, say, yellow to red as described in http://www.imagemagick.org/Usage/canvas ... l-gradient. I would like to place the resulting image over the centre of another, larger image (to simulate the laser aiming device of a speed trap).

The overlay should however consist of a circular area rather than a circle surrounded by a square. So far, I get along with creating a circular gradient with transparency and overlaying this to the final image. But this is not quite what I am trying to achive.

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-17T09:48:38-07:00
by fmw42
Wolfgang,

Not exactly sure what you want. Can you post a link to what you have and explain how you want it different?

Have you tried using -distort arc starting with a linear gradient? see http://www.imagemagick.org/Usage/distorts/#arc

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-17T11:27:30-07:00
by Bonzo
As I read it whugemann wants a circular gradiant that ends in a circle without extending to the corners of the image - like an iris. Outside the iris would be transparent to the corners.

I suppose you could create a normal circular gradiant and use a mask with a round hole?

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-17T13:30:08-07:00
by fmw42
Bonzo wrote:As I read it whugemann wants a circular gradiant that ends in a circle without extending to the corners of the image - like an iris. Outside the iris would be transparent to the corners.

I suppose you could create a normal circular gradiant and use a mask with a round hole?

I may be mistaken. You may be right. If one wants a radial gradient then do it your way. If you want an angular gradient, then -distort arc would be the way. I probably misunderstood about the radial aspect.

Alternately, try -distort polar with a linear gradient

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-17T21:31:39-07:00
by fmw42
Is this what you are trying to do:

convert -size 100x100 radial-gradient:yellow-red -transparent red radial_grad_yellow_red.png

Image

If not, can you explain what needs changing?


Or this:

convert -size 100x100 radial-gradient: -negate -black-threshold 30% -level 30%x100% +level-colors yellow,red -transparent yellow -transparent red radial_grad_yellow_red2.png

Image



Or this:

convert -size 100x50 gradient:red-yellow -virtual-pixel HorizontalTile -background none -distort arc "360 0 100 25" grad_red_yellow_arc.png


Image

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-20T03:15:54-07:00
by whugemann
Thanks Fred (and Bonzo for the explanation of my needs), this is exactly what I was looking for.

I have been experimenting with masks, but your basic idea to just define plain red as transparent is much brighter. I finally went for the linear gradient with arc distortion, as it gives you somewhat more control over what you are doing. By this way of proceeding it was quite easy to enlarge the yellow centre in the middle.

BTW: I find it quite tedious to provide example images on this board. To my knowledge, I have to upload them to my webite and embed a link over here. This is OK, but then I will have to leave that image there forever, if I don't want to break the thread in retrospective. I would prefer if small images (up to a set size of, say, 20 kB) could be uploaded directly to the discourse server.

Re: Circular Colour Gradient limited to a Circular Area

Posted: 2012-08-22T22:02:14-07:00
by anthony
Using Arc or Polar distortion to generate circular gradients is great, and often easier than using -radial-gradient.
It is also properly sampled (the reverse can not be propelry sampled using EWA (elliptical) resampling

As for displaying images on the forum...

I have a script that I use to simply upload the example to my public dropbox folder, I don't run the drop box client (which syncs the drop box folder to a local disk copy) as I dont want or need a local copy of these images. I just upload and use them. I simply don't care about them after a few months. If I did I would have a local copy anyway. Maybe when I start running out of dropbox space I'll start a new dropbox account, or just junk the lot and start again :-)

Once uploaded (simple command) then have a X window keyboard macro (Window-Ctrl-F3) that writes the URL of my dropbox folder in any input window (such as my forum edit box), and I just append the name of the file and tell the forum editor it is an image. DONE.

EG: For example fom a past upload (a constrained distance gradient example)....
Image
The first part of the image URL is a constant and unchanging, with the filename part is the same as what I uploaded. It does not use the numbered ID or hash's such as other places like flicker.com use.

If I have the dropbox web page open, it also provides pop up menus to get the 'public URL' to the clipboard.

Besides dropbox I also have a private web site, as well as facebook photo albums, and flicker photo sets, that I use for more practical images and screen shots, especially in other things I am involved with. But these I control more carefully than dropbox.