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 Rolf Schumacher <Ro...@hamburg.de> on 2002/12/02 22:43:36 UTC

transcoder output is always empty

I've got no error message
but an empty jpeg file from the following code:

Writer svg = new OutputStreamWriter(
	new FileOutputStream(new File(output)),"UTF-8");
svgGenerator.stream(svg, true); svg.flush(); svg.close();
JPEGTranscoder t = new JPEGTranscoder();
t.addTranscodingHint(
	JPEGTranscoder.KEY_QUALITY, new Float(.8));
TranscoderInput tin = new TranscoderInput(
	new File(output).toURL().toString());
Writer jout = new OutputStreamWriter(
	new FileOutputStream(new File(jpegOutput)));
TranscoderOutput tout = new TranscoderOutput(jout);
t.transcode(tin, tout); jout.flush(); jout.close();


The file "output" contains a fine svg grafic,
I can view it with the Explorer.
The file jout is generated but empty.
I'm using 1.5.4b of batik on Windows XP.

Even if I substitute the input with any batik delivered sample
the output stays empty.
Any Idea what's wrong with the code?

Rolf



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


Re: transcoder output is always empty

Posted by Rolf Schumacher <Ro...@hamburg.de>.
Thanks Felicia for your help. By trying out your hints
I found what's wrong: The problem is timing!
When my program just has written the new svg file
the underlying XP operating systgem has not finished writing.
So I cannot immediatly start and convert that svg file to jpeg.
If I do it in two Main-classes and start them manually one after the other
it does something (I got  new problems by I have some jpeg).

Rolf


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


Re: transcoder output is always empty

Posted by Felicia Ionascu <fg...@ocegr.fr>.
Rolf,

See if the paths are good.
When initialising the TranscoderInput, is it pointing to the good svg file?

Another suggestion: use the OutputStream constructor of TranscoderOutput
instead of the one using Writer.

Felicia



Rolf Schumacher wrote:

> As I got no answer I'd like to explain that the code is straight forward.
>
> // setting up the svg file - this works as it should
>
> > Writer svg = new OutputStreamWriter(
> >     new FileOutputStream(new File(output)),"UTF-8");
> > svgGenerator.stream(svg, true); svg.flush(); svg.close();
>
> // at this point the svg drawing is available
> // setting up the transcoder for jpeg translation
>
> >
> > JPEGTranscoder t = new JPEGTranscoder();
> > t.addTranscodingHint(
> >     JPEGTranscoder.KEY_QUALITY, new Float(.8));
>
> // directing transcoder input to the just generated svg drawing
>
> >
> > TranscoderInput tin = new TranscoderInput(
> >     new File(output).toURL().toString());
>
> // setting up the transcoder output to an arbitrary file
>
> >
> > Writer jout = new OutputStreamWriter(
> >     new FileOutputStream(new File(jpegOutput)));
> > TranscoderOutput tout = new TranscoderOutput(jout);
>
> // do the translation from svg to jpeg
>
> >
> > t.transcode(tin, tout); jout.flush(); jout.close();
>
> // the problem here is that the output is empty but
> // according to the example it should contain the same drawing with jpeg
> pixels
>
> Has anybody tried that? Has to work that way?
>
> Rolf
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

--
------------------------------------------------------------
 Felicia IONASCU                 Océ Print Logic Technologies
 mailto:fgi@ocegr.fr             1, rue Jean Lemoine
 phone : +33 (0)1 48 98 81 99    94015 Créteil cedex, France
 fax:    +33 (0)1 48 98 54 50    http://www.oce.com/
------------------------------------------------------------



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


Re: transcoder output is always empty

Posted by Rolf Schumacher <Ro...@hamburg.de>.
As I got no answer I'd like to explain that the code is straight forward.

// setting up the svg file - this works as it should

> Writer svg = new OutputStreamWriter(
>     new FileOutputStream(new File(output)),"UTF-8");
> svgGenerator.stream(svg, true); svg.flush(); svg.close(); 

// at this point the svg drawing is available
// setting up the transcoder for jpeg translation

>
> JPEGTranscoder t = new JPEGTranscoder();
> t.addTranscodingHint(
>     JPEGTranscoder.KEY_QUALITY, new Float(.8)); 

// directing transcoder input to the just generated svg drawing

>
> TranscoderInput tin = new TranscoderInput(
>     new File(output).toURL().toString()); 

// setting up the transcoder output to an arbitrary file

>
> Writer jout = new OutputStreamWriter(
>     new FileOutputStream(new File(jpegOutput)));
> TranscoderOutput tout = new TranscoderOutput(jout); 

// do the translation from svg to jpeg

>
> t.transcode(tin, tout); jout.flush(); jout.close(); 

// the problem here is that the output is empty but
// according to the example it should contain the same drawing with jpeg 
pixels

Has anybody tried that? Has to work that way?

Rolf



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