Blur Images in Java

In our previous posts we explained how to crop, resize, flip, and rotate images using Java. This article focuses on adding a professional blur effect to your pictures. Follow the guide below to understand how to blur images programmatically in Java with Aspose.Imaging.

Apply Blur Effect to Images in Java - API Installation

To add blur functionality, we use Aspose.Imaging for Java, a comprehensive image processing library that supports both raster and vector formats. You can obtain the library by downloading it directly or by adding the Maven repository and dependency to your project.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository> 

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-imaging</artifactId>
    <version>22.9</version>
</dependency>

After adding the dependency, run mvn clean install to download the JAR files and make the API available in your IDE.

How to Blur Images in Java

Applying a blur filter with Aspose.Imaging involves three straightforward steps:

  1. Load the source image from disk or a stream.
  2. Apply the blur filter using the filter method of RasterImage.
  3. Save the processed image to the desired output location.

These steps work for common formats such as BMP, JPEG, PNG, and TIFF, ensuring broad compatibility across Java applications.

Java Code to Blur an Image

Below is a concise code example that demonstrates each step. The comments highlight the purpose of each line.

For illustration, we applied the blur effect to the sample raster image shown below.

Input Image to Apply Blur Effect

The resulting image after applying the blur filter is displayed here.

Output Blur Image in Java

Blurring Image in Java - Get a Free License

You can get a free temporary license to test the blur functionality without evaluation restrictions.

Conclusion

This guide showed how to blur images in Java using Aspose.Imaging. By integrating the provided code snippet, developers can quickly add blur effects to any Java‑based image workflow, enhancing visual appeal and privacy protection.

Read More

You can explore more about the Java image processing API using documentation. Also, you can share your queries with us via our forum.

See Also