We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert big size images


I have a requirement to convert big size images from one format to other.

Using normal image save it give Out Of Memory exception so i tried using below code. But its still not working.

Can you please help me out and also what format does below code supports?

final RasterImage image = (RasterImage) RasterImage.load("./inputimages/input.png");

image.loadPartialPixels(image.getBounds() , new IPartialPixelLoader() {


public void process(Rectangle arg0, Color[] arg1, Point arg2, Point arg3) {

// TODO Auto-generated method stub

image.savePixels(arg0, arg1);

image.save("./outputimages/output1.jpg", new JpegOptions());





Hi Amit,

First of all, please accept our apologies for a bit delayed response.

We have evaluated your presented scenario on our end while using the below provided simplest code snippet against your sample. Unfortunately, we are unable to replicate the OutOfMemoryException with this particular image. Please note, we have set the Java Heap size to 512m on our testing platform and we recommend the same for you. Reason being, currently Aspose.Imaging APIs uses Color[] for internal structure, and this mechanism utilizes more memory as the Color[] stores additional information along with 4 bytes of color. We are in process to change the internal structure to use byte[] instead of Color[], then you will not be needing to set a higher Java Heap size, until then please set an appropriate value. Moreover, please check the article for Performance Improvement with Customizable Cache, and try by setting the cache to use disk storage for your testing.


RasterImage image = (RasterImage) RasterImage.load(inpath);
image.save(outpath, new JpegOptions());

Please note, the above code has one known drawback at the moment, that is; in cases where PNG files having transparent background are converted to JPEG, the background color renders as black. We are working on this issue under the ticket IMAGING-34134, and hope to provide the fix with next major release of Aspose.Imaging for Java.

Please feel free to write back in case you have further questions or concerns.