Get Images/Pictures Size In Excel via Java
Using Aspose.Cells’ API to work with various objects without any software like Microsoft or Open Office, Adobe PDF, etc.
How to get images/pictures size in Excel File Using Java
In order to get images/pictures size in Excel File, we’ll use
API which is a feature-rich, powerful and easy to use API for Java platform. You can download its latest version directly from
and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>version of aspose-cells API</version>
<classifier>jdk17</classifier>
</dependency>
Steps to get images/pictures size in Excel file via Java
- Loading the XLSX file with full path.
- Select Worksheet via its index.
- Select picture object via its index from ‘Pictures’ attribute of Worksheet.
- There are various ways to get the size from a selected picture object.The parts are listed below, for more information, please refer to
MORE
.Notice:‘Width’ and ‘Height’ are the dimensions shown in the excel may be larger or smaller than the original picture.
- Width Represents the width of shape, in unit of pixels.
- Height Represents the height of shape, in unit of pixel.
- OriginalWidth Gets the original width of the picture, in unit of pixels.
- OriginalHeight Gets the original height of the picture, in unit of pixels.
System Requirements
Aspose.Cells for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
- Get latest version of Aspose.Cells for Java directly from Maven.
There are also two size-related attributes ‘getWidthScale()’ and ‘getHeightScale()’, which respectively represent the percentages of the current display width and height to the actual width and height. It should be noted that there is a certain error in these two attribute values, please do not use them in the case of high precision requirements.
The following code sample demonstrates how to get the size and display zoom ratio of an image/picture.