Skip to content

Commit

Permalink
updated Resizer. Fixed opening output and input stream in same time
Browse files Browse the repository at this point in the history
  • Loading branch information
YamStranger committed Nov 22, 2015
1 parent a7bdaeb commit 4267bd9
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ public ScreenshotNegative process(ScreenshotNegative negative) {
}

private void saveResizedScreenshotTo(Path temporaryPath) throws IOException {
try (
InputStream imageStream = Files.newInputStream(temporaryPath);
OutputStream resizedImageStream = Files.newOutputStream(temporaryPath)
){
BufferedImage image = ImageIO.read(imageStream);
BufferedImage resizedImage;
try (InputStream images = Files.newInputStream(temporaryPath)) {
BufferedImage image = ImageIO.read(images);

Dimension imageSize = sizeOf(image);
Dimension targetSize = targetSizeInProportionTo(imageSize);

if (imageSize.equals(targetSize)) {
return;
}

BufferedImage resizedImage = resize(image, targetSize.width, targetSize.height);
resizedImage = resize(image, targetSize.width, targetSize.height);
}
try (OutputStream resizedImageStream = Files.newOutputStream(temporaryPath)) {
ImageIO.write(resizedImage, "png", resizedImageStream);
}
}
Expand Down

0 comments on commit 4267bd9

Please sign in to comment.