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 Padbury <dp...@liquidnet.com> on 2011/04/22 17:25:52 UTC

Transcoding SVG to PNG with svg image elements produces "Unable to make sense of URL for connection"

Hi Everyone,

I'm trying to transcode an SVG with image elements (<image xlink:href="my-image.png" ... />). This works great in the command line batik-rasterizer tool when the image is placed in the current working directory. However when rendering inside my own application (code snippet below) it is producing the exception "Unable to make sense of URL for connection". The batik-rasterizer must be providing some method of loading understanding local paths but I haven't been able to work out how.

Any suggestions?

/* Code snippet in Groovy */
def transcoder = new JPEGTranscoder()

transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));

def reader = new StringReader(svg)
def input = new TranscoderInput(reader)

def output = new TranscoderOutput(outputStream)

transcoder.transcode(input, output)
/* end of snippet */

Kind regards,

David.

Re: Transcoding SVG to PNG with svg image elements produces "Unable to make sense of URL for connection"

Posted by Christoffer Dam Bruun <cd...@flyingpigs.dk>.
Hi,

Have you tried setting the URI on the TranscoderInput ( using setURI() )

If you don't do that Batik will not be able to calculate where it should 
look for
relative path's encountered inside the input SVG.

/Christoffer

On 22-04-2011 17:25, David Padbury wrote:
>
> Hi Everyone,
>
> I'm trying to transcode an SVG with image elements (<image 
> xlink:href="my-image.png" ... />). This works great in the command 
> line batik-rasterizer tool when the image is placed in the current 
> working directory. However when rendering inside my own application 
> (code snippet below) it is producing the exception "Unable to make 
> sense of URL for connection". The batik-rasterizer must be providing 
> some method of loading understanding local paths but I haven't been 
> able to work out how.
>
> Any suggestions?
>
> /* Code snippet in Groovy */
>
> def transcoder = new JPEGTranscoder()
>
> transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));
>
> def reader = new StringReader(svg)
>
> def input = new TranscoderInput(reader)
>
> def output = new TranscoderOutput(outputStream)
>
> transcoder.transcode(input, output)
>
> /* end of snippet */
>
> Kind regards,
>
> David.
>