Page 1 of 1

Transparent overlay of grid lines imperfect

Posted: 2012-03-10T19:37:42-07:00
by djd
If a constant size grid is to be applied to a large number of images, a couple of ways to do it are:

a) Make an image of the grid on say a white background, then overlay that grid onto the images:

eg after creating the grid file

convert mapin.gif \
\( gridfile.gif -crop 2819x1542+0+0 -repage 0x0+0+0 \
-transparent white \) \
-flatten Mapout1.gif

Typical time to do this: 10 sec

b) Draw the grid directly onto the image

convert mapin.gif \
-stroke 'rgb(111,198,242)' -strokewidth 1 \
-draw "stroke-opacity 1 path 'drawstr'" \
Mapout2.gif

Typical time to do this: 60 sec

Thus a) is significantly faster than b) when 100s of images are involved.
However, the grid lines from a) consist of an unwanted white line adjacent to the required blue grid line.

Something wrong with the script?

A section of the two Mapout[12].gif can be seen at www.discway.com.au/cmad

Regards

Re: Transparent overlay of grid lines imperfect

Posted: 2012-03-11T00:20:41-07:00
by fmw42
If your b/w grid image was drawn with anti-aliased lines than -transparent white will leave the anti-aliased part (slightly darker than pure white) behind. You either need to use -fuzz with -transparent white or better draw your lines without anti-aliasing. This is just a guess on my part for your problem. You can also draw lines on an already transparent background image, so that you do not need to use -transparent white.

You can also use a different composition image with your b/w grid. I think it might be -compose screen. See http://www.imagemagick.org/Usage/compose/#screen

Re: Transparent overlay of grid lines imperfect

Posted: 2012-03-11T22:46:39-07:00
by anthony
If you image is black and white, then you can eithe ruse +level-colors to color it.
OR your -background COLOR -alpha shape to make the black parts transparent and white parts 'COLOR'. -negate the image before the -alpha shapee if you want white parts transparent.