remove dead code

This commit is contained in:
jmillman 2016-01-04 15:05:02 -05:00
parent c5ca1d55f3
commit 0d526d0933
2 changed files with 1 additions and 83 deletions

View File

@ -504,87 +504,6 @@ public class ImageUtils {
return fileHeaderBuffer; return fileHeaderBuffer;
} }
/**
* Generate an icon and save it to specified location.
*
* @param file File to generate icon for
* @param iconSize size in pixels of the thumbnail
* @param cacheFile Location to save thumbnail to
*
* @return Generated icon or null on error
*/
private static BufferedImage generateAndSaveThumbnail(AbstractFile file, int iconSize, File cacheFile) {
BufferedImage thumbnail = null;
try {
if (VideoUtils.isVideoThumbnailSupported(file)) {
if (openCVLoaded) {
thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize);
} else {
return DEFAULT_THUMBNAIL;
}
} else {
thumbnail = generateImageThumbnail(file, iconSize);
}
if (thumbnail == null) {
return DEFAULT_THUMBNAIL;
} else {
BufferedImage toSave = thumbnail;
imageSaver.execute(() -> {
try {
Files.createParentDirs(cacheFile);
if (cacheFile.exists()) {
cacheFile.delete();
}
ImageIO.write(toSave, FORMAT, cacheFile);
} catch (IllegalArgumentException | IOException ex1) {
LOGGER.log(Level.WARNING, COULD_NOT_WRITE_CACHE_THUMBNAIL + file, ex1);
}
});
}
} catch (NullPointerException ex) {
LOGGER.log(Level.WARNING, COULD_NOT_WRITE_CACHE_THUMBNAIL + file, ex);
}
return thumbnail;
}
/**
* Generate and return a scaled image
*
* @param content
* @param iconSize
*
* @return a Thumbnail of the given content at the given size, or null if
* there was a problem.
*/
@Nullable
private static BufferedImage generateImageThumbnail(AbstractFile content, int iconSize) {
try {
final ReadImageTask readImageTask = new ReadImageTask(content);
readImageTask.run();
BufferedImage bi = SwingFXUtils.fromFXImage(readImageTask.get(), null);
if (bi == null) {
return null;
}
try {
return ScalrWrapper.resizeFast(bi, iconSize);
} catch (IllegalArgumentException e) {
// if resizing does not work due to extreme aspect ratio,
// crop the image instead.
return ScalrWrapper.cropImage(bi, Math.min(iconSize, bi.getWidth()), Math.min(iconSize, bi.getHeight()));
}
} catch (OutOfMemoryError e) {
LOGGER.log(Level.WARNING, "Could not scale image (too large) " + content.getName() + ": " + e.toString()); //NON-NLS //NOI18N
} catch (Exception e) {
LOGGER.log(Level.WARNING, "ImageIO could not load image " + content.getName() + ": " + e.toString()); //NON-NLS //NOI18N
}
return null;
}
/** /**
* Get the width of the given image, in pixels. * Get the width of the given image, in pixels.
* *

View File

@ -36,7 +36,6 @@ import javax.annotation.Nonnull;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.ImageUtils;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.imagegallery.FileTypeUtils; import org.sleuthkit.autopsy.imagegallery.FileTypeUtils;
import org.sleuthkit.autopsy.imagegallery.ThumbnailCache; import org.sleuthkit.autopsy.imagegallery.ThumbnailCache;
@ -293,7 +292,7 @@ public abstract class DrawableFile<T extends AbstractFile> extends AbstractFile
try { try {
imageRef = new SoftReference<>(readImageTask.get()); imageRef = new SoftReference<>(readImageTask.get());
} catch (InterruptedException | ExecutionException exception) { } catch (InterruptedException | ExecutionException exception) {
ImageUtils.logContentError(LOGGER, Level.WARNING, getMessageTemplate(exception), this); LOGGER.log(Level.WARNING, getMessageTemplate(exception), getContentPathSafe());
} }
break; break;
} }