-
-
Notifications
You must be signed in to change notification settings - Fork 315
Photoshop Clipping Path support
Harald Kuhr edited this page Nov 16, 2020
·
1 revision
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.