Photo Filtering API: How to Emboss an Image with Java

Cloudmersive
1 min readMay 9, 2022

Looking to get your hands on a cool photo-filtering API? We’ve got just the thing for you — our Embossing API will give an input image its namesake’s 3-dimensional effect. You can take advantage of this API easily by following the three steps included below to install & copy ready-to-run Java code snippets.

To get started, install the Java SDK using Maven (instructions for Gradle can be found via our website & API console page). Add a reference to the pom.xml repository:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Then add a reference to the dependency:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Lastly, add the import classes and include the image filtering function:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.FilterApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
FilterApi apiInstance = new FilterApi();
Integer radius = 56; // Integer | Radius in pixels of the emboss operation; a larger radius will produce a greater effect
Integer sigma = 56; // Integer | Sigma, or variance, of the emboss operation
File imageFile = new File("/path/to/inputfile"); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
try {
byte[] result = apiInstance.filterEmboss(radius, sigma, imageFile);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FilterApi#filterEmboss");
e.printStackTrace();
}

--

--

Cloudmersive

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