Hey guys,
we are facing a lot of problems with the Imaging Java stack.
We are using the Image library for just resizing. I tried it with Png and Bmp files.
One problem I see is, that if I not manually call flush and close on the stream, a lot of bytes are missing. It would be a good advise, if you are going to save you should close the passed stream.
But this is not my main problem.
If I call resize I get the following stacktrace with the Bmp:
Exception in thread “main” java.lang.NullPointerException
at com.aspose.imaging.Color.CloneTo(Unknown Source)
at com.aspose.imaging.M.b(Unknown Source)
at com.aspose.imaging.M.a(Unknown Source)
at com.aspose.imaging.fileformats.bmp.BmpImage.resize(Unknown Source)
at com.saperion.sdb.spi.classicconnector.rendering.RenderImageConverter.resize(RenderImageConverter.java:127)
at com.saperion.sdb.spi.classicconnector.rendering.RenderImageConverter.main(RenderImageConverter.java:146)
With the png file:
java.lang.NullPointerException
at com.aspose.imaging.hidden.E.g.a(Unknown Source)
at com.aspose.imaging.M.b(Unknown Source)
at com.aspose.imaging.M.a(Unknown Source)
at com.aspose.imaging.hidden.f.a.a(Unknown Source)
at com.aspose.imaging.fileformats.tiff.TiffImage.resize(Unknown Source)
at com.aspose.imaging.Image.resize(Unknown Source)
at com.saperion.sdb.spi.classicconnector.rendering.RenderImageConverter.resize(RenderImageConverter.java:127)
at com.saperion.sdb.spi.classicconnector.rendering.RenderImageConverter.main(RenderImageConverter.java:145)
Used code:
InputStream imageInputStream = new ByteArrayInputStream(source);
com.aspose.imaging.Image image = Image.load(imageInputStream);
int imageWidth = image.getWidth();
// resize image
double scale = 1.0;
if (maxWidth > 0 && imageWidth > maxWidth) {
scale = (double) maxWidth / imageWidth;
}
image.resize((int)(imageWidth * scale), (int)(image.getHeight() * scale));
image.save(“D:/image_resized.png”, new PngSaveOptions());
out.flush();
out.close();
Any ideas?