Hello,
I am trying to evaluate your product and I am having problems with image resizing.
User story: I want to preview an image but if it is a large image then it should be resized on the server and send this client-side (smaller file, less bandwidth).
I have tried:
Image image = Image.load(inputFileLocation);
image.resize(100, 100);
//hard coded sizes for testing but would really want toimage.save(outputFileLocation);
// keep ratio of the original picture
Which throws a NullPointerException on the second line which I guess is related to this post is there an update to this issue?
Also tried to work around by:
BmpCreateOptions bmpCreateOptions = new BmpCreateOptions();
bmpCreateOptions.setWidth(100)//BitsPerPixel defaults to 32 where as the image I will load will be 24 and unless this is set the //output image is completely different, is there any easy way to get the file’s BitsPerPixel?
bmpCreateOptions.setHeight(100); bmpCreateOptions.setBitsPerPixel(24);
// com.aspose.imaging.Image image = Image.load(inputFileLocation);
// int bitsPerPixel = image.getBitsPerPixel();
InputStream inputStream = new FileInputStream(inputFileLocation);bmpCreateOptions.setSource(new StreamSource(inputStream));
Image im = Image.create(bmpCreateOptions); im.save(outputFileLocation);
Which, cuts a 100x100 square out of the image. I also tried saving with various XxxSaveOptions but all output is black.
BmpSaveOptions so = new BmpSaveOptions();
System.out.println("BmpSaveOptions bits per pixel: " + so.getBitsPerPixel()); //default 32
so.setBitsPerPixel(24); //hardcoded
System.out.println("BmpSaveOptions bits per pixel: " + so.getBitsPerPixel());
im.save(outputFileLocation, so);
// output still black even after setting BitsPerPixel
If you could please provide sample code that can get tif/gif/bmp/png/jpg to be resized, the output filetype doesn’t matter, any image type is acceptable. If you have one example I should be able to figure out the rest if they need slightly different implementations. Or direct me to any post or documentation that I may have missed.
Regards