Transparent overlay of grid lines imperfect

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?".
Post Reply
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Transparent overlay of grid lines imperfect

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparent overlay of grid lines imperfect

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparent overlay of grid lines imperfect

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply