Page 1 of 1

Overlay a SVG image on top of a png image

Posted: 2013-06-24T14:50:12-07:00
by yervand
Hello

Im trying to convert a pdf file to a png and then place a svg image on top of the png.

The svg contains a white background which I would like it to be transparent when placing over the png. Can someone please help me accomplish this.

I know that (in php)

exec('convert /file/filepdf.pdf /file/filepng.png');

converts the file to a png and I tried adding the following command to it to make it overlay the svg but it doesnt seem to work

exec('convert /file/filepdf.pdf /file/filepng.png -composite /file/svgfile.svg'); hoping this will place the svg file above the converted png but no luck.

Any suggestions on how i can accomplish this?

Re: Overlay a SVG image on top of a png image

Posted: 2013-06-24T23:49:31-07:00
by Bonzo
I would apply the svg and then change to png; something like:

Code: Select all

exec('convert /file/filepdf.pdf \( /file/svgfile.svg -fuzz 10% -transparent white \) -gravity center -composite /file/filepng.png '); 

Re: Overlay a SVG image on top of a png image

Posted: 2013-06-25T09:23:00-07:00
by yervand
Bonzo

This doesnt seem to work

I get the following error in my logs

convert: Memory allocation failed `/file/svgfile.svg' @ svg.c/ReadSVGImage/2825.
convert: missing an image filename `/file/filepng.png ' @ convert.c/ConvertImageCommand

Re: Overlay a SVG image on top of a png image

Posted: 2013-06-25T10:35:47-07:00
by fmw42
post links to your pdf and svg files so others can look at them and work with them