From 3e7e9ec592f2ea8ba37dd86bb53b3ebe80cc3742 Mon Sep 17 00:00:00 2001 From: jmillman Date: Wed, 30 Dec 2015 11:40:30 -0500 Subject: [PATCH] include video thumbnails in thumbnail generation task --- .../autopsy/coreutils/ImageUtils.java | 65 +++++++++++-------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java index 6ee9f2a2ae..66a31010c5 100755 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java @@ -655,36 +655,45 @@ public class ImageUtils { } } - BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null); - if (isNull(bufferedImage)) { - LOGGER.log(Level.WARNING, "Failed to read image for thumbnail generation."); - throw new IIOException("Failed to read image for thumbnail generation."); - } - updateMessage("scaling image"); - updateProgress(-1, 1); BufferedImage thumbnail = null; - try { - thumbnail = ScalrWrapper.resizeFast(bufferedImage, iconSize); - } catch (IllegalArgumentException | OutOfMemoryError e) { - // if resizing does not work due to extreme aspect ratio, crop the image instead. - logError("Could not scale image {0}: " + e.toString() + "\nAttemptying to crop {0} instead"); //NON-NLS - - final int height = bufferedImage.getHeight(); - final int width = bufferedImage.getWidth(); - if (iconSize < height || iconSize < width) { - final int cropHeight = Math.min(iconSize, height); - final int cropWidth = Math.min(iconSize, width); - - try { - thumbnail = ScalrWrapper.cropImage(bufferedImage, cropWidth, cropHeight); - } catch (Exception cropException) { - logError("Could not crop image {0}: " + cropException.toString()); //NON-NLS - throw cropException; - } + if (VideoUtils.isVideoThumbnailSupported(file)) { + if (openCVLoaded) { + thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize); + } else { + thumbnail = DEFAULT_THUMBNAIL; + } + } else { + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null); + if (isNull(bufferedImage)) { + LOGGER.log(Level.WARNING, "Failed to read image for thumbnail generation."); + throw new IIOException("Failed to read image for thumbnail generation."); + } + updateMessage("scaling image"); + updateProgress(-1, 1); + + try { + thumbnail = ScalrWrapper.resizeFast(bufferedImage, iconSize); + } catch (IllegalArgumentException | OutOfMemoryError e) { + // if resizing does not work due to extreme aspect ratio, crop the image instead. + logError("Could not scale image {0}: " + e.toString() + "\nAttemptying to crop {0} instead"); //NON-NLS + + final int height = bufferedImage.getHeight(); + final int width = bufferedImage.getWidth(); + if (iconSize < height || iconSize < width) { + final int cropHeight = Math.min(iconSize, height); + final int cropWidth = Math.min(iconSize, width); + + try { + thumbnail = ScalrWrapper.cropImage(bufferedImage, cropWidth, cropHeight); + } catch (Exception cropException) { + logError("Could not crop image {0}: " + cropException.toString()); //NON-NLS + throw cropException; + } + } + } catch (Exception e) { + logError("Could not scale image {0}: " + e.toString()); //NON-NLS + throw e; } - } catch (Exception e) { - logError("Could not scale image {0}: " + e.toString()); //NON-NLS - throw e; } updateProgress(-1, 1); if (nonNull(thumbnail) && DEFAULT_THUMBNAIL != thumbnail) {