public void createAndSaveThumbnail(File file, WebElement element) {
createAndSaveThumbnail(file, 0, element);
}
public void createAndSaveThumbnail(File file, int index, WebElement element) {
Point centerPoint = getCenter(element);
Dimension elementDimension = element.getSize();
BufferedImage image = loadImage(file);
if (centerPoint != null) {
Point cropPoint = findImageCropPoint(centerPoint, image);
int cropWidth = thumbnailWidth;
int cropHeight = thumbnailHeight;
if (elementDimension.getWidth() > thumbnailWidth) {
int newXPoint = cropPoint.getX() - (elementDimension.getWidth() / 2);
if (newXPoint < 0) {
newXPoint = 0;
}
cropPoint = new Point(newXPoint, cropPoint.getY());
}
if (image.getHeight() < thumbnailHeight) {
cropHeight = image.getHeight();
}
if (image.getWidth() < thumbnailWidth) {
cropWidth = image.getWidth();
}
image = crop(image, cropPoint.getX(), cropPoint.getY(), cropWidth, cropHeight);
} else {
if ((image.getHeight() > thumbnailHeight) || (image.getWidth() > thumbnailWidth)) {
image = resize(image, thumbnailWidth);
}