Page 1 of 1

Overlay SVG image onto JPEG (watermark)

Posted: 2013-08-30T02:04:19-07:00
by djeyewater
I would like to overlay an SVG image on top of a raster image so that the SVG image's width is 20% of the raster image's width and is placed 10% in from the bottom left edge of the image.

I've tried the following command, but it doesn't seem to affect the size or offset of the SVG at all, plus the SVG is rendered with a white background rather than being transparent:

Code: Select all

composite -compose atop -geometry "20%+10%" -gravity southwest watermark.svg photo.jpg photo-watermarked.jpg
You can see the result image here: http://www.iliveinabin.com/ImageMagick- ... marked.jpg
Made from this SVG: http://www.iliveinabin.com/ImageMagick- ... ermark.svg
And this photo: http://www.iliveinabin.com/ImageMagick- ... /photo.jpg

I realise I can get the end result I'm looking for by using a PNG and pixel values for the geometry, but ideally I'd like to get the more flexible solution using an SVG working.

Thanks

Dave

Re: Overlay SVG image onto JPEG (watermark)

Posted: 2013-08-30T10:20:30-07:00
by fmw42
I am not sure that -geometry using % values. If it does then you still need the + sign. If it does not, then you need to convert the % values to pixels. see http://www.imagemagick.org/script/comma ... p#geometry in the section about offsets. It looks like it does not support %.

Also you should use the convert syntax and set the density on the svg file before reading it to set the size of the converted svg file.

something like

convert photo.jpg -density XX watermark.svg -gravity southwest -geometry "+X+Y" -compose atop photo-watermarked.jpg

Re: Overlay SVG image onto JPEG (watermark)

Posted: 2013-08-30T13:11:01-07:00
by snibgo
The converted SVG image has no transparency because, by defalt, IM puts it on an opaque white background. Defeat this by putting "-background none" before the SVG file. The only transparency occurs in the top corners.

You might choose a different "-compose" operation. Perhaps "-compose Multiply" gives what you want.

Re: Overlay SVG image onto JPEG (watermark)

Posted: 2013-09-01T12:44:20-07:00
by djeyewater
Thanks for the suggestions, after adding -background none I was still having an issue with opacity of the SVG shape being 100% rather than the 50% set in the SVG. I did some searching and found that rather than setting opacity on the <g> containing the shape path, fill-opacity="0.5" should be set on the path that makes up the shape. All working how I wanted now.

Thanks again!

Dave