How to emboss an image in Python

A wide range of images can be spiced up with embossing, so let’s look at how to set this up. The manual method is out, as that can take quite a while. Rather, let’s use a simplified solution: an API. This is going to be easy, just wait.

So let’s install our client first — use this command for pip install:

pip install cloudmersive-image-api-client

Now we can set up the function calling code for filter_emboss.

from __future__ import print_functionimport timeimport cloudmersive_image_api_clientfrom 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 emboss operation; a larger radius will produce a greater effectsigma = 56 # int | Sigma, or variance, of the emboss operationimage_file = '/path/to/file' # file | Image file to perform the operation on.  Common file formats such as PNG, JPEG are supported.try:# Emboss an imageapi_response = api_instance.filter_emboss(radius, sigma, image_file)pprint(api_response)except ApiException as e:print("Exception when calling FilterApi->filter_emboss: %s\n" % e)

And finally, our image_file can be entered, as well as our sigma and variance to govern our effect. Send your request and shortly thereafter you should have the finished embossed image. Almost too easy. Let’s try it on this photo:

Image for post

Below is our embossed image with radius: 25 and sigma: 3.

Image for post

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store