How to convert a PowerPoint PPTX into a Thumbnail PNG Image in Node.JS

Cloudmersive
2 min readMay 30, 2020

--

Converting a PowerPoint presentation into a thumbnail is a surprisingly complex and difficult thing to do. It requires multiple format conversions, as well as slide separation and image resizing. I won’t get into all the pitfalls that can arise from all these steps. Instead I will give you a get-out-of-jail-free card in the form of an API that is custom-built for creating thumbnails from virtually any file format out there.

With npm install, let’s retrieve our client files.

npm install cloudmersive-convert-api-client --save

And now set up a simple API function call using a key:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var opts = {'maxWidth': 56, // Number | Optional; Maximum width of the output thumbnail - final image will be as large as possible while less than or equal to this width. Default is 128.'maxHeight': 56, // Number | Optional; Maximum height of the output thumbnail - final image will be as large as possible while less than or equal to this width. Default is 128.'extension': "extension_example" // String | Optional; Specify the file extension of the inputFile. This will improve the response time in most cases. Also allows unsupported files without extensions to still return a corresponding generic icon.};var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentAutodetectToThumbnail(inputFile, opts, callback);

And the rest is pretty self-explanatory. Run the code, get your thumbnail. Easy.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.