How to Convert ODP to JPG in Python

Cloudmersive
2 min readJul 6, 2020

--

If you need a quick and easy means of converting between formats, then today’s post is just what you need. We will be covering how to quickly achieve results when working between ODP and JPG, allowing you to avoid all the tedious parsing and rasterizing that would normally go into this process. How can we make it so easy? We will be using an API that is equipped to handle the problem for us. We’ll be done in two steps.

First is our installation:

pip install cloudmersive-convert-api-client

Second, we need to call our API function for ODP to JPG.

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.quality = 56 # int | Optional; Set the JPEG quality level; lowest quality is 1 (highest compression), highest quality (lowest compression) is 100; recommended value is 75. Default value is 75. (optional)try:# Convert ODP Presentation to JPG/JPEG image arrayapi_response = api_instance.convert_document_odp_to_jpg(input_file, quality=quality)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_odp_to_jpg: %s\n" % e)

Now run it and you will get back a response object containing a set of byte arrays, which are your images.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet