How to Convert Keynote KEY to PNG in Python

File format conversion is a huge headache, but often a necessary one. Both the size of the headache and the necessity are amplified ten-fold when working with Mac formats outside of their native habitat. If you would rather not get into all the details of parsing Keynote format, then I have just the solution for you. We can have you set up to convert your .KEY files into PNG images for each slides in a very short time indeed. Let’s begin.

We start with our client installation.

pip install cloudmersive-convert-api-client

Now for our function call, for which you can use this example code as a basis.

from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom 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 Keynote Presentation (KEY) to PNG image arrayapi_response = api_instance.convert_document_keynote_to_png(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_keynote_to_png: %s\n" % e)

And there you have it; all done! Our output will be given in this format:

"Successful": true,
"PngResultPages": [
"PageNumber": 0,
"URL": "string"

Each of the pages will have its own download URL, making it super easy to get your results.

Image for post

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store