A PowerPoints presentation is usually comprised of Text, Images, Charts, Shapes etc and we may have a requirement to only extract PPT images for further processing. So in this article, we are going to discuss the details on how to extract images from PPTX online using Java Cloud SDK. The API provides the leverage to extract the images in specified format including JPEG, PNG, GIF, BMP or TIFF. Furthermore, in order to extract images, we can either load the presentation from Cloud storage or upload it from local drive.
PowerPoint Processing API
Aspose.Slides Cloud is REST based API offering capabilities to create, process PPT and convert PowerPoint to other supported formats. Now in order to utilize the same PowerPoint processing features in Java application, Aspose.Slides Cloud SDK for Java is a reliable solution. Its a wrapper around Cloud API and can easily be integrated in Java application by adding its reference through pom.xml file.
<repositories> <repository> <id>aspose-cloud</id> <name>artifact.aspose-cloud-releases</name> <url>http://artifact.aspose.cloud/repo</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-slides-cloud</artifactId> <version>22.9.0</version> </dependency> </dependencies>
In case you do not have an existing account over Aspose Cloud, please please create a free account using valid email address. Then login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required for authentication purposes in the following sections.
Extract PPT images in Java
This section explains the details on how to extract PPT images using Java code snippet. We are going to load PowerPoint from cloud storage and extract all the images from PowerPoint. The extracted images are returned as a single .zip archive. Please follow the instructions specified below.
- First of all, create an object of SlidesApi object while providing ClientID and Client secret as arguments
- Secondly, create an instance of File which takes address of input PowerPoint template file as parameter
- Thirdly, read the content of PowerPoint files using readAllBytes(…) and save it in byte array
- Next step is to upload the PPT to Cloud storage using uploadFile(…) method
- Finally call the downloadImages(…) method while providing ImageExportFormat.JPEG enumeration value so that images are extracted in JPG format
The sample presentation template used in above example can be downloaded from RainbowPresentation.potx.
Extract Images from PPTX using cURL Commands
Now lets explore the details on how to extract images from PPTX online using cURL commands. So the first step is to generate a JWT access token (based on client credentials) while executing the following command.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
Once we have the JWT token, please execute the following command to next step is to merge PowerPoint presentations using following command. Please note that in following command, we are extracting all PowerPoint images in JPEG format. The extracted images are then saved to local drive in .zip archive format.
curl -v -X POST "https://api.aspose.cloud/v3.0/slides/input.potx/images/download/Jpeg" \ -H "accept: multipart/form-data" \ -H "authorization: Bearer <JWT Token>" \ -o output.zip
This article has explained the details on how to extract PPT images using Java Cloud SDK. At the same time, since the API is based on REST architecture, so we can also access it through cURL commands to accomplish similar requirements. Apart from this feature, the API provides an wide array of features and therefore, we highly recommend exploring product Documentation. Also, please note that all our Cloud SDKs are published under MIT license, so you may consider downloading the complete source code from GitHub and modify it as per your requirements. In case of any issues, you may consider approaching us for a quick resolution via free product support forum.
Please visit the following links to learn more about: