SVGImageReader: Can't overwrite cause with java.awt.image.ImagingOpException: Unable to transform src image
See original GitHub issueSome SVG files cause an exception in TwelveMonkeys:
java.lang.IllegalStateException: Can't overwrite cause with java.awt.image.ImagingOpException: Unable to transform src image
at java.lang.Throwable.initCause(Throwable.java:457)
at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.readImage(SVGImageReader.java:538)
at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.getImage(SVGImageReader.java:562)
at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.access$200(SVGImageReader.java:262)
at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader.read(SVGImageReader.java:141)
...
This is because the TranscoderException already initializes the throwable cause with null and thus initCause cannot be called:
catch (Exception ex) {
TranscoderException exception = new TranscoderException(ex.getMessage());
exception.initCause(ex);
throw exception;
}
So it should be changed into something like this:
catch (Exception ex) {
TranscoderException exception = new TranscoderException(ex.getMessage(), ex);
throw exception;
}
Alright, but this is not such a big issue. What worries me is the original exception to begin with:
java.awt.image.ImagingOpException: Unable to transform src image
Now, since you are using an ARGB image already, this seems to be a Batik bug that it in turn seems to be caused by a Java bug (see this)…
The images that cause these exceptions are in the Batik sample folder as follows: batikYin.svg logoShadowOffset.svg textRotateShadows.svg
The problem (at least in the examples above, there may be other triggers) goes way if you edit the feGaussianBlur’s stdDeviation parameter in the XML to use only one argument.
For example, this causes the exception:
<feGaussianBlur stdDeviation="2 3" />
but this does not:
<feGaussianBlur stdDeviation="2" />
I don’t think there is much that can be done to fix the ImagingOpException
but it is just to let you know
: )
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Well, it does work in OpenJDK 9 in Linux!!
Excellent. Closing this (I will probably fix the exception issue at some point though).
– Harald K