Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-818

TranscoderException and EnclosedException when transcoding SVG to JPEG

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • 1.8
    • None
    • SVG Rasterizer
    • None
    • Operating System: Linux
      Platform: PC

    Description

      Hi,
      when I try to follow the description on
      http://xmlgraphics.apache.org/batik/using/transcoder.html#createImage
      to create a jpg-image file from a svg-file in a JUnitTest, I get the following error message:

      org.apache.batik.transcoder.TranscoderException: null
      Enclosed Exception:
      null
      at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:132)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
      at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
      at de.vitronic.test.TestJPEGTranscoder.testJPEGTranscoder(TestJPEGTranscoder.java:57)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      The batik version I use is 1.7.

      First I tried to transform a created svg-file into jpeg-file in my own application, but I get the same exception, so I copied the example code from the previous mentioned website in a JUnit-Testcase to figure out if I have done anything wrong in my application. But I got the same problem again, with the copied and pasted code (see above).

      When I ran the rasterizer.jar file to convert the image, there is no such an exception thrown. I looked at the code from SVGGenerator from the Rasterizer application, but I doesn´t found a solution, so far to solve the problem.

      So here is the code from my JUnitTest method:

      public void testJPEGTranscoder() {

      // 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;
      try

      { svgURI = new File("test/TestInput.svg").toURL().toString(); TranscoderInput input = new TranscoderInput(svgURI); // Create the transcoder output. OutputStream ostream = new FileOutputStream( "test/TestOutput.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); }

      catch (MalformedURLException e)

      { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }

      catch (TranscoderException e)

      { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }

      }

      Thanks in advance for your help,
      ks

      Attachments

        Activity

          People

            batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
            ks@vitronic.de ks
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: