Photoshop Clipping Path support - haraldk/TwelveMonkeys GitHub Wiki
Either, read the image with the path applied:
try (ImageInputStream stream = ImageIO.createImageInputStream(new File("image_with_path.jpg")) {
BufferedImage image = Paths.readClipped(stream);
// Do something with the clipped image...
}
Or read the image and path separately (this is basically what readClipped(stream) does):
try (ImageInputStream stream = ImageIO.createImageInputStream(new File("image_with_path.jpg")) {
Shape clip = Paths.readPath(stream);
stream.seek(0);
BufferedImage image = ImageIO.read(stream);
if (clip != null) {
image = Paths.applyClippingPath(clip, image);
}
// Do something with the clipped image...
}
This allows reusing the clip for multiple images, or modifying the clip before applying etc.