Convert Input Image to Photoshop (PSD) Format in Python
If you’re working in Photoshop, PSD format images are the way to go. Not only is PSD native to Photoshop, but it can retain a much larger number of pixels than other formats and can be edited across several different layers. Using the /image/convert/to/psd iteration of the Cloudmersive Convert API, you can easily convert documents to PSD files from a wide variety of input formats. Let’s look at how you can leverage this API in Python, using ready-to-run code from the Cloudmersive API console.
To begin, first use the Python SDK installation command below:
pip install cloudmersive-image-api-client
Next, you can begin the call back function with the below code snippets. At this stage you’ll need to authenticate your API key; if you don’t already have one, you can make one for free on the Cloudmersive website:
from __future__ import print_function
import time
import cloudmersive_image_api_client
from cloudmersive_image_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_image_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
Finally, you can complete the callback function using the below code snippet:
# create an instance of the API class
api_instance = cloudmersive_image_api_client.ConvertApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/inputfile' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try:
# Convert input image to Photoshop PSD format
api_response = api_instance.convert_to_photoshop(image_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ConvertApi->convert_to_photoshop: %s\n" % e)