resize loaded gifs

This commit is contained in:
millmanorama 2017-03-21 13:45:21 +01:00
parent 028407c04e
commit 80abec5f13

View File

@ -303,7 +303,14 @@ public class ImageUtils {
public static BufferedImage getThumbnail(Content content, int iconSize) {
if (content instanceof AbstractFile) {
AbstractFile file = (AbstractFile) content;
if (ImageUtils.isGIF(file)) {
try {
return ScalrWrapper.resizeHighQuality(ImageIO.read(new BufferedInputStream(new ReadContentInputStream(file))), iconSize, iconSize);
} catch (IOException iOException) {
LOGGER.log(Level.WARNING, "Failed to get thumbnail for " + getContentPathSafe(content), iOException); //NON-NLS
return DEFAULT_THUMBNAIL;
}
} else {
Task<javafx.scene.image.Image> thumbnailTask = newGetThumbnailTask(file, iconSize, true);
thumbnailTask.run();
try {
@ -312,6 +319,7 @@ public class ImageUtils {
LOGGER.log(Level.WARNING, "Failed to get thumbnail for " + getContentPathSafe(content), ex); //NON-NLS
return DEFAULT_THUMBNAIL;
}
}
} else {
return DEFAULT_THUMBNAIL;
}
@ -334,12 +342,12 @@ public class ImageUtils {
}
/**
* Get the location of the cached thumbnail for a file with the given fileID
* as a java File. The returned File may not exist on disk yet.
* Get the location,as a java File, of the cached thumbnail for an file with
* the given fileID . The returned File may not exist on disk yet.
*
* @param fileID the fileID to get the cached thumbnail location for
*
* @return a File object representing the location of the cached thumbnail.
* @return A File object representing the location of the cached thumbnail.
* This file may not actually exist(yet). Returns null if there was
* any problem getting the file, such as no case was open.
*/