How to Apply a Gaussian Blur using Python

2 min readFeb 1


Whether you’re reducing the noise in an image simply targeting an interesting visual effect, the Gaussian Blur technique is a great one to have in your arsenal. With the free-to-use API below, you can easily implement this service into your applications with zero hassle using ready-to-run Python code examples to structure your API call.

To begin, first install the SDK by running the following command:

pip install cloudmersive-image-api-client

Next, add the imports and call the function with the below snippet. When structuring your request parameters, you’ll need to first include your image file path (of course) for the operation, and then specify the radius and sigma of the Gaussian operation:

from __future__ import print_function
import time
import cloudmersive_image_api_client
from 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))
radius = 56 # int | Radius in pixels of the blur operation; a larger radius will produce a greater blur effect
sigma = 56 # int | Sigma, or variance, of the gaussian blur operation
image_file = '/path/to/inputfile' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.

# Perform a guassian blur on the input image
api_response = api_instance.filter_gaussian_blur(radius, sigma, image_file)
except ApiException as e:
print("Exception when calling FilterApi->filter_gaussian_blur: %s\n" % e)

That’s all there is to it! If you’re unfamiliar with how sigma impacts this operation, I recommend trying out different values on your images until you find the right balance.

To authenticate your API call, simply visit our website and register a free account. This provides a free-tier API key with a limit of 800 API calls per month (and no commitments).




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