Install our API client with pip install, the command for which is shown here:
pip install cloudmersive-image-api-client
We should write out our function call next and specify its parameters:
from __future__ import print_functionimport timeimport cloudmersive_image_api_clientfrom cloudmersive_image_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_image_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_image_api_client.FilterApi(cloudmersive_image_api_client.ApiClient(configuration))radius = 56 # int | Radius in pixels of the blur operation; a larger radius will produce a greater blur effectsigma = 56 # int | Sigma, or variance, of the gaussian blur operationimage_file = '/path/to/file' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try:# Perform a guassian blur on the input imageapi_response = api_instance.filter_gaussian_blur(radius, sigma, image_file)pprint(api_response)except ApiException as e:print("Exception when calling FilterApi->filter_gaussian_blur: %s\n" % e)
Now we need to provide filter_gaussian_blur with an image, radius, and sigma to create our effect. That’s really all there is to it; the API will created the blurred image and then return a URL for its download location. Let’s give it a whirl on this crisp image here:
Our results look like this with a radius of 10 and sigma of 5:
Softened up quite a bit.