PPT to JPG in Node.js

convert ppt to jpg

PowerPoint presentations are useful for data and information sharing, corporate briefings, lectures in universities, etc. But in order to view the presentation files, you need to have a specific application which may include installation and licensing costs. However, the raster image formats such as JPEG, PNG, GIF, BMP, etc can be viewed on any platform including Desktop or mobile devices. In this article, we are going to discuss the PPT to JPEG image conversion.

PowerPoint processing API

Aspose.Slides Cloud is a REST-based API offering the capabilities to read, edit and convert PowerPoint presentations in the cloud. Extract the contents like text and images or render the PPT files to TIFF, PDF, XPS, HTML, etc, or other Supported Document Formats. No MS Office automation or any other application is required. Perform all the PPT processing in the Cloud on any platform of your choice i.e. Desktop, Web, or Mobile App.

Node.js SDK

We have created a wrapper around Aspose.Slides Cloud API named Aspose.Slides Cloud SDK for Node.js which provides all the capabilities of PowerPoint creation, manipulation, and conversion within Node.js application. No additional software download is required. The Cloud SDK is so amazing that you can process major Microsoft PowerPoint as well as OpenOffice file formats.

Installation

In order to get started, the first step is to install the download and install the Cloud SDK on the local system. Albeit it is available for download at NPM and GitHub but we are going to use the following command to install it from NPM.

npm i asposeslidescloud

In order to ensure data protection and integrity, only authorized persons can access the Cloud services. So the next step is to create a Free account subscription on Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Client Credentials

PPT to JPG in Node.js

Please follow the instructions given below to perform the PPT to JPEG conversion operation using Node.js.

  • First we need to add the references of classes from asposeslidescloud package
  • Create two const instances holding Client ID and Client Secret details
  • Now we need to create an object of SlidesApi class while passing ClientID and Client Secret details as arguments
  • The next step is to create an object of PostSlidesConvertRequest class where we set the output format and input PPT file content
  • Now call the postSlidesConvert()… method of SlidesApi class and pass PostSlidesConvertRequest object as an argument
  • Print conversion response in console

Convert PPT to JPG using cURL

We also get the leverage to access REST API using the cURL commands over the command line terminal. But, as our APIs are only accessible to authorized users only, so we need to first generate JWT access token based on Client ID and Client Secret details as specified on Aspose.Cloud dashboard. Please execute the following command to generate the JWT access token.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=718e4235-8866-4ebe-bff4-f5a14a4b6466&client_secret=388e864b819d8b067a8b1cb625a2ea8e" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

The next step is to convert the PPT file already available on cloud storage to JPG using following cURL command. Please note that we are only converting the slide at index 2 to JPEG format. The Width value is specified as 600, Height value is specified as 800 and the name of resultant file is MyConverted.jpeg.

curl -X PUT "https://api.aspose.cloud/v3.0/slides/Animated%20PowerPoint.ppt/slides/2/Jpeg?outPath=MyConverted.jpeg&width=600&height=800" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"Format\": \"Jpeg\"}"

Request URL

https://api.aspose.cloud/v3.0/slides/Animated%20PowerPoint%20template.pptx/slides/3/Jpeg?outPath=MyConverted.jpeg&width=600&height=800
PPT to JPEG preview

The sample files used in above example can be downloaded from following links

Conclusion

We have explored the capabilities of Aspose.Slides Cloud SDK for Node.js to render PPT files to raster image (JPEG) format. As you have noticed, the conversion is so simple that few code lines can do all the processing without loosing any content or compromising the output quality. Furthermore, we have also seen the steps on how to perform the similar conversion using the cURL commands over the command line terminal. You may also download the complete source code of SDK available on GitHub.

Please try using the API and in case you encounter any issue, please feel free to contact via Free Product support forum.

Related Articles

We also suggest you to explore following articles and learn about: