You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by David Delbecq <de...@oma.be> on 2008/02/01 17:07:07 UTC

Questions about transcoding SVG to PNG

Hello,

Am trying to use transcoder API to convert an existing SVG to a PNG. I 
followed docs here: 
http://xmlgraphics.apache.org/batik/using/transcoder.html  and looked at 
sources of Rasterizer tool, but am lost at several points. I have 
several requirements for which i can't seem to easily locate solution in 
docs:

1st: size of svg is not known by code, it should be discovered by 
looking at SVG file ("natural" size of svg, if that makes sense). 
However, rasterizer requires me to specify a size that is equal or 
bigger than svg size if i want to see everything. Otherwise it's 
truncated. Is there a way to have transcoder use the svg size, instead 
of being force to provide one?

2nd: I need to add a css to that svg. I see rasterizer is able to do it. 
However, it uses map.put(ImageTranscoder.KEY_USER_STYLESHEET_URI, 
userStylesheetURL);  That mean i have to put my css in a file prior to 
use it. The css being generated on the fly (the main reason why we need 
to transcode svg to png at every request), i have it inside a 
java.lang.String. Is there a way to provide that css string to 
transcoder directly? Without ressorting to a uri?

3rd: A bit linked to (1), is there a way to provide transcoder with a 
"scale" factor, so it would render at twice the size or half the size? 
We would like or rendering process

Thanks for help

-- 
David Delbecq
Institut Royal Météorologique
Ext:557


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Questions about transcoding SVG to PNG

Posted by Tonny Kohar <to...@gmail.com>.
Hi,

On Feb 1, 2008 11:07 PM, David Delbecq <de...@oma.be> wrote:
> Hello,
>
> Am trying to use transcoder API to convert an existing SVG to a PNG. I
> followed docs here:
> http://xmlgraphics.apache.org/batik/using/transcoder.html  and looked at
> sources of Rasterizer tool, but am lost at several points. I have
> several requirements for which i can't seem to easily locate solution in
> docs:
>
> 1st: size of svg is not known by code, it should be discovered by
> looking at SVG file ("natural" size of svg, if that makes sense).
> However, rasterizer requires me to specify a size that is equal or
> bigger than svg size if i want to see everything. Otherwise it's
> truncated. Is there a way to have transcoder use the svg size, instead
> of being force to provide one?

I think it is depend on your svg content, if all of your width/height
attribute is specified as "%" percent, then there is no way to know
the size of svg, unless you are using absolute lenght eg: px, etc. One
workaround is to use viewbox or width and height attribute in the
outer svg element. By default If I am not wrong Batik will use 400x400
when the size is not specified or unknown unless overidden.

> 2nd: I need to add a css to that svg. I see rasterizer is able to do it.
> However, it uses map.put(ImageTranscoder.KEY_USER_STYLESHEET_URI,
> userStylesheetURL);  That mean i have to put my css in a file prior to
> use it. The css being generated on the fly (the main reason why we need
> to transcode svg to png at every request), i have it inside a
> java.lang.String. Is there a way to provide that css string to
> transcoder directly? Without ressorting to a uri?

I haven't tried yet, but maybe you could open the svg document (it is
just xml file) and insert your generated css into that document then
transcode


Cheers
Tonny Kohar
-- 
Sketsa SVG Editor
imagine, design, create ...
http://www.kiyut.com

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org