Generate JPG from SVG using Apache Batik
<p>I'm trying to turn a <em>.svg</em> file into a <em>.jpg</em> or <em>.png</em> file. Right now I'm trying to use <strong>Apache Batik Transcoder</strong> (<a href="https://xmlgraphics.apache.org/batik/" rel="nofollow">Link</a>).</p>

<p><strong>This is my code right now:</strong> (official code from <a href="https://xmlgraphics.apache.org/batik/using/transcoder.html" rel="nofollow">here</a>)</p>

<pre><code>// Create a JPEG transcoder
JPEGTranscoder t = new JPEGTranscoder();

// Set the transcoding hints.
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
    new Float(.8));

// Create the transcoder input.
String svgURI = new File("C:/test.svg").toURL().toString();
TranscoderInput input = new TranscoderInput(svgURI);

// Create the transcoder output.
OutputStream ostream = new FileOutputStream("C:/out.jpg");
TranscoderOutput output = new TranscoderOutput(ostream);

// Save the image.
t.transcode(input, output);

// Flush and close the stream.
ostream.flush();
ostream.close();
System.exit(0);
</code></pre>

<p>But it gives my this error:</p>

<blockquote>
  <p>Exception in thread "main" org.apache.batik.transcoder.TranscoderException: null</p>
  
  <p>Enclosed Exception:</p>
  
  <p>null</p>
  
  <p>at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)</p>
  
  <p>at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)</p>
  
  <p>at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)</p>
  
  <p>at SaveAsJPEG.main(SaveAsJPEG.java:27)</p>
</blockquote>

<p>I don't know what to do as this is the code from their website (!). So if you know how to solve it or have another idea how I can turn my .svg pictures into .jpg and .png's let me know.</p>