---
# System prepended metadata

title: JH Labs
tags: [imaging]

---

# JH Labs

###### tags: `imaging`

---

## Dependency[🔗](https://mvnrepository.com/artifact/com.jhlabs)

```xml
<dependency>
	<groupId>com.jhlabs</groupId>
	<artifactId>filters</artifactId>
	<version>2.0.235-1</version>
</dependency>
```

## 油畫[🔗](http://www.jhlabs.com/ip/filters/OilFilter.html)

```java
@GetMapping(path = "/oilPainting/{filename:\\d+}", produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
void oilPainting(@PathVariable String filename, @RequestParam(defaultValue = "10") int levels, @RequestParam(defaultValue = "10") int range, HttpServletResponse response) throws IOException {
	OilFilter oilFilter = new OilFilter();
	oilFilter.setLevels(levels);
	oilFilter.setRange(range);

	BufferedImage sourceBufferedImage = ImageIO.read(
		new ClassPathResource(filename)
	).getInputStream(), targetBufferedImage = new BufferedImage(
		sourceBufferedImage.getWidth(),
		sourceBufferedImage.getHeight(),
		sourceBufferedImage.getType()
	);

	oilFilter.filter(
		sourceBufferedImage,
		targetBufferedImage
	);
	ImageIO.write(
		targetBufferedImage,
		"JPG",
		response.getOutputStream()
	);
}
```
