Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
I'm investigating the new GradientImage method in 6.4.4-2, with the new RadialGradient support. I've created a little montage so I can see the difference between the different SpreadMethod values. Here it is:
I'm not able to see much difference in the LinearGradient results. Should I? Or is that limited to the RadialGradient type?
Proper use of the gradient requires SVG, MVG, or the drawing API. The gradient: and radial-gradient: formats are not very useful with only two stop colors and with offsets that span the image width and height. We thought about allowing defines (-define) to alter how these formats behave but we would quickly end up replicating what we already do with the rendering engine.
As an aside, Anthony pointed out the linear gradients are on a 45 degree angle which is a bug. We have a patch in the Subversion trunk and will include it of course in the next point release within a week or two.
As an aside, for the RMagick community (in case you missed it)-- the latest versions of ImageMagick address performance bottlenecks and includes support for parallel processing on dual and quad-core processors. Existing RMagick scripts should, in most cases, show a significant speed up.
rmagick wrote:I'm investigating the new GradientImage method in 6.4.4-2, with the new RadialGradient support. I've created a little montage so I can see the difference between the different SpreadMethod values. Here it is:
I'm not able to see much difference in the LinearGradient results. Should I? Or is that limited to the RadialGradient type?
I have been trying to figure out how to generate these gradients using -draw, but am getting nowhere. The docs on the MVG page are not explanatory enough. Can you identify the command line commands one uses with -draw to generate the examples you have here.
I can't help but think I'm overlooking something really obvious.
I'm getting the message "no image vector graphics `test.mvg'. See below. I looked at coders/mvg.c, which sends this message if the GetImageArtifact function returns NULL for the "MVG" key.
You need to build ImageMagick without rsvg support otherwise SVG rendering does not use the internal SVG renderer. Add something like --without-rsvg to your configure command line or edit coders/svg.c and change MAGICKCORE_RSVG_DELEGATE to something like MAGICKCORE_NO_RSVG_DELEGATE. In the mean-time ImageMagick generates this MVG for your file:
The gradient drawing method is working perfectly-- what is missing is the finishing touches on the gradient parser that sets the GradientInfo structure with multiple color stops. A fix for this problem is on our to-do list.
If you have the RSVG library configuration installed you should be able to force IM to use the internal method for a SVG image, by prefixing it with MSVG:
However I have yet to see the effects of the new gradient, in images.
I may have to build a non RSVG version to check it out, even though it should be availabel via the MSVG: input coder.
magick wrote:The gradient: and radial-gradient: formats are not very useful with only two stop colors and with offsets that span the image width and height.
Can the image generator radial-gradient: be modified to produce a circular gradient more like
that is the gradient goes from center to top edge, rather than the current center to corner?
That way users can generate a complete circular gradient and trim it is desired, rather than the clipped version that is currently generated.
magick wrote:The gradient: and radial-gradient: formats are not very useful with only two stop colors and with offsets that span the image width and height.
Can the image generator radial-gradient: be modified to produce a circular gradient more like
that is the gradient goes from center to top edge, rather than the current center to corner?
That way users can generate a complete circular gradient and trim it is desired, rather than the clipped version that is currently generated.
This is great. Thanks. I did not know that this was available as a direct IM option without -draw.
Just some ideas to think about. I don't know about the complexity of doing so, however and not a high priority.
1) Actually both options would be nice --- max at edge and max at corner.
2) When the image is not square, however, you now get the gradient to max dimension. Options to min dimension and to make an ellipse would also be nice. The latter may be more useful.
FYI: This feature (radial gradient) has potential utility in generating frequency domain filters (if we ever get FFT development into IM).
Hold on Fred. As Cristy said before, it would be hard to figure out an option set that would continue to allow easy use (like gradient: does currently) with all the numerous options that users may like to have available.
I'm not saying that it isn't possible, just a lot more work. If you can come up with some structure for the original 'gradient:' with 'styles', 'color-stops' and 'repeat' methods. that still allows the current 'easy to use' defination, especially if it better corresponds with SVG, then maybe, someone might take time to implement it.
At the moment Cristy is just trying to get SVG and MVG gradients working, which is a more important first step. The radial-gradient: feature was just something he mentioned above and I took a look at. I was suprised it had even been added.
I just felt changing the outer point from a corner to some fixed edge (top would be most logical) would at least allow users to better define the radius, and make the whole gradient visible. And it was better for such a change to be made as early as posible.
And any other 'options' would have entailed a lot more work, and make it different to the other two gradient image generators gradient: and plasma: which is basically a fractal color distortion on top of the normal gradient: base image.
I too like to see a lot more options. But I prefer to get the SVG gradient working for most. However if Cristy wants I'll jump into the code radial-gradient code and change it as I suggested. Or if you can come up with a good 'options' method. I'll gladly try to implement it to. But most importantly it must fall back to easy to use, just as gradient: has been for the last decade.
Think about it and wour out some scheme to implement it using a simple but expandable string.
Remember currently you can specify a gradient as
''
'{one_color}'
'{one_color}-{two_color}'
See IM examples for an indication of how these three styles currently work.
Anthony, feel free to fix the radial gradient to default to something sensible. Just make sure you restrict your patches to GradientImage() rather than DrawGradientImage().
The best way to add options is to use the -define or -set (e.g. -define radial-gradient:radius=0.2).
Folks, we're working on the gradient parser in the drawing renderer but it may take some time given the current demands on our time. Stand by...