MagickShadowImage
Posted: 2007-01-03T17:28:29-07:00
I would like to add drop shadows to thumbnails. It appears that MagickShadowImage may be at least part of a solution.
After much headscratching, I went to the source code and managed to figure out that the first two arguments are expected in the interval [0...100] and are the desired mean (Gaussian distribution) and standard deviation of the percentage of transparency. (Be nice if the doc said that. )
In Microsoft Image Composer, I am used to setting transparency and hardness/softness using a sliding scale. The standard deviation of transparency would seem to be equivalent to the softness slider. The x and y arguments would seem to represent the ditance of the point light source that creates the shadow. But not the angle?
Starting with a wand containing an image 175 x 131 pixels, my program calls:
MagickShadowImage(wand,10,10,5,5)
The returned image is 215 x 171 pixels. OK. Sounds reasonable. Unfortunately, when displayed on a white background, this image was totally blank. Upon further investigation I found the following image statistics:
Max Min Mean
R 255 255 255
G 255 255 255
B 255 255 255
A 255 239.4 230
Aha! The shadow image is totally white, with opacity from 90 to 100%, with a mean of 93.9%. MIC has a color argument.
So, my question now is, how do I get a shadow with black pixels, or perhaps, navy?
Am I correct in deducing that what I do now is place this shadow image over a solid color opaque image of the same size, then place the original over the top left corner of that and flatten them?
And get a different light source angle by rotating the shadow?
I may get the hang of this yet!
After much headscratching, I went to the source code and managed to figure out that the first two arguments are expected in the interval [0...100] and are the desired mean (Gaussian distribution) and standard deviation of the percentage of transparency. (Be nice if the doc said that. )
In Microsoft Image Composer, I am used to setting transparency and hardness/softness using a sliding scale. The standard deviation of transparency would seem to be equivalent to the softness slider. The x and y arguments would seem to represent the ditance of the point light source that creates the shadow. But not the angle?
Starting with a wand containing an image 175 x 131 pixels, my program calls:
MagickShadowImage(wand,10,10,5,5)
The returned image is 215 x 171 pixels. OK. Sounds reasonable. Unfortunately, when displayed on a white background, this image was totally blank. Upon further investigation I found the following image statistics:
Max Min Mean
R 255 255 255
G 255 255 255
B 255 255 255
A 255 239.4 230
Aha! The shadow image is totally white, with opacity from 90 to 100%, with a mean of 93.9%. MIC has a color argument.
So, my question now is, how do I get a shadow with black pixels, or perhaps, navy?
Am I correct in deducing that what I do now is place this shadow image over a solid color opaque image of the same size, then place the original over the top left corner of that and flatten them?
And get a different light source angle by rotating the shadow?
I may get the hang of this yet!