@@ -77,7 +77,37 @@ public T withThumbnail(String path, String name, double scale) {
7777 FileUtil .writeImage (thumbnailImage , EXTENSION , thumbnailFile );
7878 return self ();
7979 }
80-
80+
81+ /**
82+ * Generate cropped thumbnail of the original screenshot.
83+ * Will save different thumbnails depends on when it was called in the chain.
84+ *
85+ * @param path to save thumbnail image to
86+ * @param name of the resulting image
87+ * @param scale to apply
88+ * @return instance of type Snapshot
89+ */
90+ public T withCroppedThumbnail (String path , String name , double scale , double cropWidth , double cropHeight ) {
91+ File thumbnailFile = new File (path .toString (), name );
92+ if (!Files .exists (Paths .get (path ))) {
93+ thumbnailFile .mkdirs ();
94+ }
95+ thumbnailImage =ImageProcessor .cropAndScale (image ,scale , cropWidth , cropHeight );
96+ FileUtil .writeImage (thumbnailImage , EXTENSION , thumbnailFile );
97+ return self ();
98+ }
99+
100+ /**
101+ * Generate cropped thumbnail of the original screenshot.
102+ * Will save different thumbnails depends on when it was called in the chain.
103+ *
104+ * @param scale to apply
105+ * @return instance of type Snapshot
106+ */
107+ public T withCroppedThumbnail (double scale , double cropWidth , double cropHeight ) {
108+ return withCroppedThumbnail (Paths .get (location .toString (), "./thumbnails" ).toString (), "thumb_" + fileName , scale ,cropWidth ,cropHeight );
109+ }
110+
81111 /**
82112 * Generate a thumbnail of the original screenshot.
83113 * Will save different thumbnails depends on when it was called in the chain.
0 commit comments