Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG images containing image/png;base64 data fail to open #14

Open
imagejan opened this issue Jun 15, 2020 · 2 comments
Open

SVG images containing image/png;base64 data fail to open #14

imagejan opened this issue Jun 15, 2020 · 2 comments

Comments

@imagejan
Copy link
Member

Some SVG images, such as this collection of ImageJ logos committed by @elevans, fail to open in Fiji and generate the following error:

org.apache.batik.bridge.BridgeException: file:/Users/eglinger/Downloads/logos/image_logo_src.svg:2,574
The URI "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAAjhJREFU eJzt3cFRhEAQQNHG8mJImoRZGJRZmISG5BFPlLhVIrKzzHT//+7quP0ZZFnKaZ7nOYR113sB6ssA 4AwAzgDgDADOAOAMAM4A4AwA7r73Ao74fH88/LUPTx8NV5KfOwCcAcAZAJwBwBkAnAHAGQCcAcAZ AJwBwBkAnAHAGQCcAcAZAJwBwBkAnAHAGQBcys8EtjBN081/RoYHr90B4AwAzgDgDADOAOAMAM4A 4AwAzgDgDADOAOAMAM4A4AwADns7eO+t2jNuG/fkDgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYA ZwBwBgBnAHAGAGcAcAYAN/nv47dd84mgDC+tOwCcAcAZAJwBwBkAnAHAGQDcsE8Gvb2c/0TO8+v4 1+2tuQPA+U7gH6q/EzjsKWBL9aGcyVMAHC6A/+we1R8NjwAGoJ+QAew5sglHf0Tiq4BWA7r89W/1 fUeV8iqgJcqR/hvkKUDf0gYw8hY78toupQ1AbaQOYMQjbcQ1bUkdgK6XPoCRjriR1rJX+gAixnjh R1jDESUCiOg7gKzDjygUQESfQWQefkSxACLOHUj24UcUDCDinMFUGH5E4XsBy4Bav9dfZfCLsgEs WoVQbfCL8gEs1gPcG0PVoa9hAlgjDHavkn8Eaj8DgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4Az ADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgPsCiHBw1Cor 9iYAAAAASUVORK5CYII= "
on element <image> can't be opened because:
URL data in unsupported format or corrupt
	at org.apache.batik.bridge.UserAgentAdapter.getBrokenLinkDocument(UserAgentAdapter.java:448)
	at org.apache.batik.bridge.SVGImageElementBridge.createRasterImageNode(SVGImageElementBridge.java:641)
	at org.apache.batik.bridge.SVGImageElementBridge.createImageGraphicsNode(SVGImageElementBridge.java:339)
	at org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(SVGImageElementBridge.java:179)
	at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(SVGImageElementBridge.java:121)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:213)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
	at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
	at sc.fiji.io.SVG_Reader.run(SVG_Reader.java:53)
	at ij.IJ.runUserPlugIn(IJ.java:230)
	at ij.IJ.runPlugIn(IJ.java:193)
	at ij.IJ.runPlugIn(IJ.java:182)
	at HandleExtraFileTypes.tryPlugIn(HandleExtraFileTypes.java:525)
	at HandleExtraFileTypes.tryOpen(HandleExtraFileTypes.java:366)
	at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:485)
	at HandleExtraFileTypes.run(HandleExtraFileTypes.java:72)
	at ij.IJ.runUserPlugIn(IJ.java:230)
	at ij.IJ.runPlugIn(IJ.java:193)
	at ij.IJ.runPlugIn(IJ.java:182)
	at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:516)
	at ij.io.Opener.openImage(Opener.java:370)
	at ij.io.Opener.openImage(Opener.java:242)
	at ij.io.Opener.open(Opener.java:109)
	at ij.io.Opener.openAndAddToRecent(Opener.java:291)
	at ij.plugin.DragAndDrop.openFile(DragAndDrop.java:192)
	at ij.plugin.DragAndDrop.run(DragAndDrop.java:159)
	at java.lang.Thread.run(Thread.java:748)

This might be solved by updating to the latest batik version, but I didn't have a chance to test this yet.

I found this related discussion in a quick search:

https://issues.apache.org/jira/browse/BATIK-1125

@elevans
Copy link

elevans commented Jun 15, 2020

@imagejan this is almost certainly because I'm using inkscape to create the logo. Inkscape uses its own version of .svg format which contains extra information to maintain layers etc...

I'll make the filename clear about that and include some more clear language in the readme.

https://inkscape.org/develop/about-svg/

@imagejan
Copy link
Member Author

Thanks @elevans for the information. I still think it might be caused by the base64-coded rastered images in the svg file (i.e. the old ImageJ logo, right?). But we need to test it, and if we can't improve the IO behavior, we can at least handle the BridgeException and display a more user-friendly error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants