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 Alexandre Djioev <al...@socialchange.net.au> on 2001/07/26 10:19:16 UTC

SVG to PNG

Hello All,

A have a chunk of code which converts SVG to PNG:
  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);

	try {
         	pngTranscoder.transcode(svgInput, imageOutput);
	   } catch (Exception e) {System.out.println ("can't transform SVG
to PNG."); };



It works and looks good for me, but I also want to define somewhere the
size of the output PNG image (width/height). Is it possible somehow to
implement?



-- best regards,
	Alexandre Djioev


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


Re: SVG to PNG

Posted by Thierry Kormann <tk...@ilog.fr>.
On Friday 27 July 2001 06:46, Alexandre Djioev wrote:
> Thierry,
>
> I tryed to do what you said, but all the time I get an exeption:
>  Exception 400 incompatible with
> org.apache.batik.transcoder.keys.LengthKey@ffb38
>
> I just add thouse two strings:
>
>
>               pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH,
> new Integer(width));
>               pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT,
> new Integer(height));

According to the Transcoder tutorial, the keys have to be java.lang.Float 
objects.

see: http://xml.apache.org/batik/rasterizerTutorial.html


Thierry.

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


Re: SVG to PNG

Posted by Thierry Kormann <tk...@ilog.fr>.
On Friday 27 July 2001 06:46, Alexandre Djioev wrote:
> Thierry,
>
> I tryed to do what you said, but all the time I get an exeption:
>  Exception 400 incompatible with
> org.apache.batik.transcoder.keys.LengthKey@ffb38
>
> I just add thouse two strings:
>
>
>               pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH,
> new Integer(width));
>               pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT,
> new Integer(height));
>
> What am I doing wrong?

Both KEY_WIDTH and KEY_HEIGHT are Float not Integer.
For futher details, see the Transcoder tutorial:

http://xml.apache.org/batik/rasterizerTutorial.html

Thierry.

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


Re: SVG to PNG

Posted by Alexandre Djioev <al...@socialchange.net.au>.
Thierry,

I tryed to do what you said, but all the time I get an exeption:
 Exception 400 incompatible with
org.apache.batik.transcoder.keys.LengthKey@ffb38

I just add thouse two strings:


              pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH,
new Integer(width));
              pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT,
new Integer(height));

What am I doing wrong?




On Thu, 26 Jul 2001, Thierry Kormann wrote:

> On Thursday 26 July 2001 10:19, Alexandre Djioev wrote:
> > Hello All,
> >
> > A have a chunk of code which converts SVG to PNG:
> >   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);
> >
> > 	try {
> >          	pngTranscoder.transcode(svgInput, imageOutput);
> > 	   } catch (Exception e) {System.out.println ("can't transform SVG
> > to PNG."); };
> >
> >
> >
> > It works and looks good for me, but I also want to define somewhere the
> > size of the output PNG image (width/height). Is it possible somehow to
> > implement?
>
> You can use the TranscodingHints: WIDTH and HEIGHT that let you define the
> size of the image. In addition to that, the TranscodingHint AOI let you
> define an area of interest inside the image (it's the area that will be
> rasterized).
>
> Finally, you can have a look at the Transcoder tutorial.
> http://xml.apache.org/batik/rasterizerTutorial.html
>
> Thierry.
>

-- 
best regards,
	Alexandre Djioev


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


Re: SVG to PNG

Posted by Thierry Kormann <tk...@ilog.fr>.
On Thursday 26 July 2001 10:19, Alexandre Djioev wrote:
> Hello All,
>
> A have a chunk of code which converts SVG to PNG:
>   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);
>
> 	try {
>          	pngTranscoder.transcode(svgInput, imageOutput);
> 	   } catch (Exception e) {System.out.println ("can't transform SVG
> to PNG."); };
>
>
>
> It works and looks good for me, but I also want to define somewhere the
> size of the output PNG image (width/height). Is it possible somehow to
> implement?

You can use the TranscodingHints: WIDTH and HEIGHT that let you define the 
size of the image. In addition to that, the TranscodingHint AOI let you 
define an area of interest inside the image (it's the area that will be 
rasterized).

Finally, you can have a look at the Transcoder tutorial.
http://xml.apache.org/batik/rasterizerTutorial.html

Thierry.


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