Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -67,12 +68,27 @@ public T withTitle(String title) {
*/
public T withThumbnail(String path, String name, double scale) {
File thumbnailFile = new File(path.toString(), name);
thumbnailFile.mkdirs();
if(Files.exists(Paths.get(path))) {
thumbnailFile.mkdirs();
}
thumbnailImage=ImageProcessor.scale(image,scale);
FileUtil.writeImage(thumbnailImage, extension, thumbnailFile);
return self();
}

/**
* Generate a thumbnail of the original screenshot.
* Will save different thumbnails depends on when it was called in the chain.
*
* @param path to save thumbnail image to
* @param name of the resulting image
* @param scale to apply
* @return instance of type Snapshot
*/
public T withThumbnail(Path path, String name, double scale) {
return withThumbnail(path.toString(),name,scale);
}

/**
* Generate a thumbnail of the original screenshot.
* Will save different thumbnails depends on when it was called in the chain.
Expand All @@ -81,8 +97,7 @@ public T withThumbnail(String path, String name, double scale) {
* @return instance of type Snapshot
*/
public T withThumbnail(double scale) {
withThumbnail(Paths.get(location.toString(),"./thumbnails").toString(),"thumb_"+fileName,scale);
return self();
return withThumbnail(Paths.get(location.toString(),"./thumbnails").toString(),"thumb_"+fileName,scale);
}

/**
Expand Down Expand Up @@ -112,7 +127,9 @@ protected void setImage(BufferedImage image) {
*/
public void save() {
File screenshotFile = new File(location.toString(), fileName);
screenshotFile.mkdirs();
if(Files.exists(location)) {
screenshotFile.mkdirs();
}
if (title != null && !title.isEmpty()) {
image = ImageProcessor.addTitle(image, title, Color.red, new Font("Serif", Font.BOLD, 20));
}
Expand Down