How to Convert ODP to PNG in Python
Sometimes it’s much more convenient to have a presentation file in image form instead. Unfortunately, making the conversion between ODP and PNG is certainly not a trivial one. The presentation needs to be split into individual pages, which then have to each be rendered and rasterized into images. If you don’t feel like dealing with any of that, I have a much simpler means of accomplishing this. Give me a couple minutes and we can get you all set up.
First we install the client for the API that we will be using.
pip install cloudmersive-convert-api-client
Now we can use that API to call the conversion function for ODP to PNG.
from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_convert_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_convert_api_client.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Convert ODP Presentation to PNG image arrayapi_response = api_instance.convert_document_odp_to_png(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_odp_to_png: %s\n" % e)
And if you run that you will get back a JSON object with download links for each of your PNG images. No sweat.