Chart and picture toImage on apply horizonal and vertical resolution not properly work

Hi,


Chart and picture toImage(0 method with image format png and vertical and horizontal resolution not behave properly.

As I apply resolution as 300 it will shrink the size of image.
This will work fine if apply on SheetRender toImage method.

Code:

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setImageFormat(ImageFormat.getPng());
imgOptions.setOnePagePerSheet(true);
imgOptions.setHorizontalResolution(300);
imgOptions.setVerticalResolution(300);

chart.toImage(filePath, imgOptions);

Error:
1. The image shrinked as resoultion increase and expend when decrease.
2. In case of Picture the picture output comes to be on full page and rest of the area becomes black.

Hi,

Please try our latest version/fix:Aspose.Cells for Java (Latest Version) , if it works fine.

If you still find the issue, kindly attach your Excel file, we need to test your case on our end.

Thank you.

Hi,


Same issue persist with this build I am sending you my xlsx file and the output chart image for better clerification.

Attached Files:
1. Sample xlsx file
2. Png file with 300 resolution
3. Png file with 72 resolution

Hi,

Thanks for your posting and using Aspose.Cells for Java.

We have tested your issue with the following code and it works fine. Could you provide us your complete runnable sample code replicating this issue. It will help us look into your precisely.

Java


String filePath = “F:\Shak-Data-RW\Downloads\Sample2.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(0);


Chart chart = worksheet.getCharts().get(0);


ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

imgOptions.setImageFormat(ImageFormat.getPng());

imgOptions.setOnePagePerSheet(true);

imgOptions.setHorizontalResolution(300);

imgOptions.setVerticalResolution(300);


chart.toImage(filePath + “.out.png”);



Yes, I agreed your code works file beacuse you hadn’t apply ImageOrPrintOptions on it.


You use
chart.toImage(filePath);
instead of
chart.toImage(filePath, imgOpts);

Hi,

Thanks for your posting and using Aspose.Cells for Java.

We are able to observe this issue after making the code modifications and applying image options. We have logged this issue in our database. We will look into it and fix this issue. Once, the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40626.

Hi,

Thanks for your posting and using Aspose.Cells for Java.

We have fixed this issue.

Please download and try this fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-40626) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello


I have used a Aspose.Cells for Java 7.7.0.4, but have the same issue. May be don’t understand using of method, but i expect to receive the image of chart with size 800px x 600px, but have received 7459x3775

public void copyRange() {
try {
Workbook wbk=new Workbook(“D:\imagetest.xlsx”);

Chart chart = wbk.getWorksheets().get(1).getCharts().get(0);

/* File f = new File(“D:\out.png”);
try (FileOutputStream out = new FileOutputStream(f)) {*/
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getPng());
options.setOnePagePerSheet(true);
options.setHorizontalResolution(800);
options.setVerticalResolution(600);
chart.toImage(“D:\out.png”, options);
//}

} catch (Exception e) {
e.printStackTrace();
}
}


Best regards. Alexey

Hi Alexey,

Thanks for your posting and using Aspose.Cells for Java.

Setting vertical and horizontal resolution actually sets number of dots per inch. So when you will set it, it will make the image file size increase and decrease. If you specify more dots per inch, then image size will increase. If you will specify less dots per inch, image size will decrease but it will not make the image as horizontal px X vertical px.

Specifying 800 and 600 means there will be 800 dots per inch horizontally and 600 dots per inch vertically, it will not make the image actually 800px x 600px.

Thanks for reply. There is exists a way to set width and height of resulting image in pixels?


UPD:
I have found a way do this.


Hi Alexey,

Thanks for using Aspose.Cells.

It is good to know that you were able to sort out this issue. You can share your solution here if you like. It will be helpful for other users too.

Let us know if you face any other issue. We will be glad to help you further.