How to Swirl Distort an Image using Python
Swirl distortion is a common way to imbue images with a unique look. The below API solution allows you to filter images with a swirl distortion effect in only a few lines of code & with very basic request parameters (requiring only your image file and the desired number of degrees for your swirl).
To take advantage of this API, first run this following command to install the SDK:
pip install cloudmersive-image-api-client
And then call the function (first adding the imports):
from __future__ import print_function
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'
# create an instance of the API class
api_instance = cloudmersive_image_api_client.FilterApi(cloudmersive_image_api_client.ApiClient(configuration))
degrees = 56 # int | Degrees of swirl
image_file = '/path/to/inputfile' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
# Swirl distort the image
api_response = api_instance.filter_swirl(degrees, image_file)
except ApiException as e:
print("Exception when calling FilterApi->filter_swirl: %s\n" % e)
To complete your API call, make sure you pass a valid Cloudmersive API key with your request. You can get one for free by registering a free account on our website (this allows a limit of 800 API calls per month with no additional commitments).