I'm trying to do an SGV image conversion to PNG, but I'm having some issues.
My code:
String svg_URI_input = Paths.get("/home/ivan/Documentos/imagem/Svg2.svg").toUri().toURL().toString();
TranscoderInput input_svg_image = new TranscoderInput(svg_URI_input);
OutputStream png_ostream = new FileOutputStream("/home/ivan/Documentos/imagem/tica.png");
TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);
// Step-3: Create PNGTranscoder and define hints if required
PNGTranscoder my_converter = new PNGTranscoder();
// Step-4: Convert and Write output
my_converter.transcode(input_svg_image, output_png_image);
// Step 5- close / flush Output Stream
png_ostream.flush();
png_ostream.close();
}
Exception:
on element <image> can't be opened because:
URL data in unsupported format or corrupt
at org.apache.batik.bridge.UserAgentAdapter.getBrokenLinkDocument(Unknown Source)
at org.apache.batik.bridge.SVGImageElementBridge.createRasterImageNode(Unknown Source)
at org.apache.batik.bridge.SVGImageElementBridge.createImageGraphicsNode(Unknown Source)
at org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(Unknown Source)
at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at convertsvgtopng.ConvertSvgToPng.main(ConvertSvgToPng.java:46)
Exception in thread "main" org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
file:/home/ivan/Documentos/imagem/Svg2.svg:0
on element <image> can't be opened because:
URL data in unsupported format or corrupt
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at convertsvgtopng.ConvertSvgToPng.main(ConvertSvgToPng.java:46)
Java Result: 1