SeadragonExporter crashes when run through Toolkit
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Gephi |
Fix Committed
|
High
|
Bertrand Fan |
Bug Description
I am using the Toolkit to try to export via the SeadragonExporter. I extracted the org-gephi-
My code looks like this:
SeadragonExporter exporter = new SeadragonExport
exporter.
Workspace currentWorkspace = Lookup.
exporter.
exporter.
exporter.
exporter.
exporter.
exporter.execute();
which throws this error:
Exception in thread "main" java.lang.
at org.gephi.
at org.gephi.
at org.gephi.
Caused by: java.lang.
at java.awt.
at java.awt.
at com.thebuzzmedi
at com.thebuzzmedi
at com.thebuzzmedi
at com.thebuzzmedi
at org.gephi.
at org.gephi.
at org.gephi.
... 2 more
I ran it through the debugger and it looks like what's happening is SeadragonExport
writeLevel then creates an image with this code:
BufferedImage scaledImage = Scalr.resize(image, Scalr.Method.
But as you can see, when we get down to the final level, 0:
main[1] print level
level = 3
main[1] print levelScale
levelScale = 0.001953125
main[1] cont
>
Breakpoint hit: "thread=main", org.gephi.
main[1] print level
level = 2
main[1] print levelScale
levelScale = 9.765625E-4
main[1] cont
>
Breakpoint hit: "thread=main", org.gephi.
main[1] print level
level = 1
main[1] print levelScale
levelScale = 4.8828125E-4
main[1] cont
>
Breakpoint hit: "thread=main", org.gephi.
main[1] print level
level = 0
main[1] print levelScale
levelScale = 2.4414062E-4
The levelScale is so small that levelScale * image.getWidth() approximates to 0, which throws the exception because we can't create an image with a width or a height of 0. I've tried running deepZoom on my exported image normally and it looks like at the 0 level it is a 1x1 pixel image anyway.
Can we patch the code to return 1 instead of 0 for the calculation if it calculates to 0?
Thank you for the report, having 1 as a min seems the right thing to do. Can you provide a patch? I'll apply it asap and release a new version.