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 Vincent Hardy <vh...@eng.sun.com> on 2001/05/11 03:28:06 UTC

Re: Converting SVG to Image - SVG format problems

Alexandre,

I think the SVG is invalid because the rgb() functions are missing
commas between the r/g and g/b values. For example, it uses 
rgb(51 204 255) instead of rgb(51,204,255). From the CSS2 spec:

"The format of an RGB value in the functional notation is ’rgb(’
followed by a
comma-separated list of three numerical values (either three integer
values or
^^^^^^^^^^^^^^^
three percentage values) followed by ’)’."

So my take is that there is a problem with the tool that generates the 
SVG.

I hope this helps.
Vincent.

Alexandre Djioev wrote:
> 
> Hello All,
> 
>          I've got following problem:
>          threre is an SVG file which I've got from some other program
>          (mapstyler, it convers GML into SVG), and then I want to
>          transform this SVG output into png (for example). Here is the
>          code:
> 
>         <parser>
>         private byte[] SVGtoPNG() {
> 
>        System.out.println ("SVG Stream converting");
>        PNGTranscoder pngTranscoder = new PNGTranscoder();
>        pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
>                                          "org.apache.xerces.parsers.SAXParser");
> 
> 
>                 TranscoderInput svgInput = new TranscoderInput(new ByteArrayInputStream(value));
> 
>                 ByteArrayOutputStream outStream = new ByteArrayOutputStream();
>                 TranscoderOutput imageOutput = new TranscoderOutput(outStream);
>                // File imageFile = new File("test.png");
> 
>         try {
>                 // TranscoderOutput imageOutput = new TranscoderOutput(new FileOutputStream(imageFile));
>                 pngTranscoder.transcode(svgInput, imageOutput);
>            } catch (Exception e) {System.out.println ("can't transform SVG to PNG."); };
> 
> 
> 
> 
>           return outStream.toByteArray();
> 
>         }
>         </parser>
> 
>         This code works with SVG samples which I've got from web
>         (some SVG samples), but it gives me an exception with SVG
>         files from mapstyler... SVGviewer can display them, so
>         syntax looks fine. I attached one mapstyler SVG file to this
>         letter, so can someone tell me what's wrong?
>         Actually I found one problem -
>           <path style="stroke-width:0.1;fill:rgb(51 204 255);stroke:rgb(51 204 255);"
> 
>           in this string we have name:function, and batik complains
>           that it must be name:value. Still SVGviewer accept this.
>           Just try to convert this ocean.svg into png...
>           So who is right and who is wrong  - Batik or mapstyler?
> 
> 
> 
> --
> Best regards,
>  Alexandre                          mailto:alexd@socialchange.net.au
> 
>   ------------------------------------------------------------------------
>                 Name: ocean.svg
>    ocean.svg    Type: Scalable Vector Graphics (image/svg)
>             Encoding: base64
> 
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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