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 Nico Hÿffffe9monic <he...@yahoo.fr> on 2004/04/29 16:45:53 UTC

Pb transcoding a SVG file into PNG

Hi everybody,
 
I would like to convert a svg file into a png file (I would prefer GIF file, but it is not
implemented yet).
When I try to transcode my svg, everything seems to go right until the end of the program.
In fact, the program does not finish well. It seems that some threads are still alive and waiting
for something. Last but not the least: My PNG file is not created! 

Here is my code (it is the same as the example of Batik)

	PNGTranscoder t = new PNGTranscoder();
	// create the transcoder input
	String svgURI = new File("C:\\partage\\test.svg").toURL().toString();
	TranscoderInput input = new TranscoderInput(svgURI);
	// create the transcoder output
	OutputStream ostream = new FileOutputStream("testNHEM.png");
	TranscoderOutput output = new TranscoderOutput(ostream);
	// save the image
	t.transcode(input, output);
	// flush and close the stream then exit
	ostream.flush();
	ostream.close();

Here are the list of the thread which stay alive:
- SunToolkit.PostEventQueue
- AWT-EventQueue
- AWT-Windows

I have tried to put "System.exit(0)" at the end, but the PNG file is still not created.

Do you know what goes wrong?

Thanks in advance for your help

Nicolas


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

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


Pb transcoding a SVG file into PNG

Posted by Nicolas Hemonic <he...@yahoo.fr>.
Hi Mathias,

> I also create PNG files and it works without createNewFile(). Normally
> the file is automatically created.
Seeing the batok default example, I thought that it would have run without creating the file.
But, in my case, if I do not create the file before, it does not work.
Perhaps when the thread hanging problem will be solved it will work fine.

I am going to make some tests.

Nicolas


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

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


Re: Pb transcoding a SVG file into PNG

Posted by Mathias Kalb <ma...@prodato-it.de>.
Hi Nicolas,

> I finally succeed in creating the png file. The thing wrong was that I did not created 
> (File.createNewFile) the png file before making an outputstream on it.
> In the example of batik, there is no advising about that. I thought that the file was created
> automatically. But it is not :-)

I also create PNG files and it works without createNewFile(). Normally
the file is automatically created.

Ciao
Mathias Kalb



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


Re: Pb transcoding a SVG file into PNG

Posted by Marc Chung <mc...@fastq.com>.
Hi Nicolas,

You should be able to configure Eclipse (I'm guessing WSAD too) to use a 
different JRE System Library.  If you are in the DOS console AND threads 
are hanging, your "main" method would not end, unless you call 
System.exit(0).  The fact that the program, which you ran in DOS w/ 
JDK1.4, appears to be finished (you get the command prompt) tells me 
that 1.3 was the problem. 

--Marc


Nicolas Hemonic wrote:

>Hi Marc,
>
>  
>
>>However, it is possible that your hanging thread has nothing to do with this. 
>>If you can test the code in a 1.4 environment, it would confirm the
>>problem/solution.
>>    
>>
>All of my code is in Websphere Studio Application Developper (WSAD) 5.0.
>So the JDK is the 1.3.
>I made a test by exporting the code and running it in a batch with a jdk 1.4.
>The batch stop friendly (without system.exit(0))
>To complete the test, I try with a 1.3 java version.
>The batch stop friendly (without system.exit(0)) too.
>
>So, does the problem come from WSAD?
>or, perhaps, in the DOS console, if some threads are still hanging, it does not show them and the
>program appears to be finished...
>
>I do not know if this test is concluding
>
>
>	
>
>	
>		
>Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
>Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
>
>Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com
>
>---------------------------------------------------------------------
>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


Re: Pb transcoding a SVG file into PNG

Posted by Nicolas Hemonic <he...@yahoo.fr>.
Hi Marc,

> However, it is possible that your hanging thread has nothing to do with this. 
> If you can test the code in a 1.4 environment, it would confirm the
> problem/solution.
All of my code is in Websphere Studio Application Developper (WSAD) 5.0.
So the JDK is the 1.3.
I made a test by exporting the code and running it in a batch with a jdk 1.4.
The batch stop friendly (without system.exit(0))
To complete the test, I try with a 1.3 java version.
The batch stop friendly (without system.exit(0)) too.

So, does the problem come from WSAD?
or, perhaps, in the DOS console, if some threads are still hanging, it does not show them and the
program appears to be finished...

I do not know if this test is concluding


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

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


Re: Pb transcoding a SVG file into PNG

Posted by Marc Chung <mc...@fastq.com>.
Hi Nicolas,

I did a search for AWT headless, and I found this:
http://java.sun.com/j2se/1.4.2/docs/guide/awt/AWTChanges.html#headless

However, it is possible that your hanging thread has nothing to do with this. 
If you can test the code in a 1.4 environment, it would confirm the
problem/solution.

Best,
Marc

Quoting Nicolas Hemonic <he...@yahoo.fr>:

> Hi Marc,
> 
> I finally succeed in creating the png file. The thing wrong was that I did
> not created 
> (File.createNewFile) the png file before making an outputstream on it.
> In the example of batik, there is no advising about that. I thought that the
> file was created
> automatically. But it is not :-)
> 
> But, I still have the pb of the hanging thread.
> In fact, this code will go into an applet which will run in a 1.4.1
> environment, but for the
> moment, I am with the JDK 1.3.0 in a normal application, so I think your
> explaination is correct.
> But (sorry, my english is not fluent), what do you mean by headlessly? I
> understand word by word
> (head-less-ly) but not in this context...
> 
> Thanks for your help!
> 
> Nicolas
> 
> 
>  --- Marc Chung <mc...@fastq.com> a écrit : 
> > About the hanging thread:
> > Are you using JDK 1.3.x?  If you are, I believe this happening because AWT
> can't
> > run headlessly in 1.3.x.
> > 
> > About the file not being created:
> > Have you tried setting your OutputStream to an absolute path.  ie.
> > "C:\\testNHEM.png".    
> 
> 
> 
> 	
> 
> 	
> 		
> Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
> Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
> 
> Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez
> Yahoo! Messenger sur http://fr.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 




-------------------------------------------------
FastQ Communications 
Providing Innovative Internet Solutions Since 1993


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


Re: Pb transcoding a SVG file into PNG

Posted by Nicolas Hemonic <he...@yahoo.fr>.
Hi Marc,

I finally succeed in creating the png file. The thing wrong was that I did not created 
(File.createNewFile) the png file before making an outputstream on it.
In the example of batik, there is no advising about that. I thought that the file was created
automatically. But it is not :-)

But, I still have the pb of the hanging thread.
In fact, this code will go into an applet which will run in a 1.4.1 environment, but for the
moment, I am with the JDK 1.3.0 in a normal application, so I think your explaination is correct.
But (sorry, my english is not fluent), what do you mean by headlessly? I understand word by word
(head-less-ly) but not in this context...

Thanks for your help!

Nicolas


 --- Marc Chung <mc...@fastq.com> a écrit : 
> About the hanging thread:
> Are you using JDK 1.3.x?  If you are, I believe this happening because AWT can't
> run headlessly in 1.3.x.
> 
> About the file not being created:
> Have you tried setting your OutputStream to an absolute path.  ie.
> "C:\\testNHEM.png".    



	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

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


Re: Pb transcoding a SVG file into PNG

Posted by Marc Chung <mc...@fastq.com>.
About the hanging thread:
Are you using JDK 1.3.x?  If you are, I believe this happening because AWT can't
run headlessly in 1.3.x.

About the file not being created:
Have you tried setting your OutputStream to an absolute path.  ie.
"C:\\testNHEM.png".    


--Marc

Quoting Nico Hÿffffe9monic <he...@yahoo.fr>:

> Hi everybody,
>  
> I would like to convert a svg file into a png file (I would prefer GIF file,
> but it is not
> implemented yet).
> When I try to transcode my svg, everything seems to go right until the end of
> the program.
> In fact, the program does not finish well. It seems that some threads are
> still alive and waiting
> for something. Last but not the least: My PNG file is not created! 
> 
> Here is my code (it is the same as the example of Batik)
> 
> 	PNGTranscoder t = new PNGTranscoder();
> 	// create the transcoder input
> 	String svgURI = new File("C:\\partage\\test.svg").toURL().toString();
> 	TranscoderInput input = new TranscoderInput(svgURI);
> 	// create the transcoder output
> 	OutputStream ostream = new FileOutputStream("testNHEM.png");
> 	TranscoderOutput output = new TranscoderOutput(ostream);
> 	// save the image
> 	t.transcode(input, output);
> 	// flush and close the stream then exit
> 	ostream.flush();
> 	ostream.close();
> 
> Here are the list of the thread which stay alive:
> - SunToolkit.PostEventQueue
> - AWT-EventQueue
> - AWT-Windows
> 
> I have tried to put "System.exit(0)" at the end, but the PNG file is still
> not created.
> 
> Do you know what goes wrong?
> 
> Thanks in advance for your help
> 
> Nicolas
> 
> 
> 	
> 
> 	
> 		
> Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
> Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
> 
> Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez
> Yahoo! Messenger sur http://fr.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 




-------------------------------------------------
FastQ Communications 
Providing Innovative Internet Solutions Since 1993


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