mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
fix some image reading bugs, to preserve animated gifs, and contain failure to read swf files.
This commit is contained in:
parent
1a0001c911
commit
55381fd9be
@ -429,6 +429,7 @@ public class ImageUtils {
|
|||||||
String cacheDirectory = Case.getCurrentCase().getCacheDirectory();
|
String cacheDirectory = Case.getCurrentCase().getCacheDirectory();
|
||||||
return Paths.get(cacheDirectory, "thumbnails", fileID + ".png").toFile(); //NOI18N
|
return Paths.get(cacheDirectory, "thumbnails", fileID + ".png").toFile(); //NOI18N
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Could not get cached thumbnail location. No case is open.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,6 +657,10 @@ public class ImageUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected javafx.scene.image.Image call() throws Exception {
|
protected javafx.scene.image.Image call() throws Exception {
|
||||||
|
if (isGIF(file)) {
|
||||||
|
return readImage();
|
||||||
|
}
|
||||||
|
|
||||||
// If a thumbnail file is already saved locally, just read that.
|
// If a thumbnail file is already saved locally, just read that.
|
||||||
if (cacheFile != null && cacheFile.exists()) {
|
if (cacheFile != null && cacheFile.exists()) {
|
||||||
try {
|
try {
|
||||||
@ -670,16 +675,19 @@ public class ImageUtils {
|
|||||||
|
|
||||||
//There was no correctly-sized cached thumbnail so make one.
|
//There was no correctly-sized cached thumbnail so make one.
|
||||||
BufferedImage thumbnail = null;
|
BufferedImage thumbnail = null;
|
||||||
|
|
||||||
if (VideoUtils.isVideoThumbnailSupported(file)) {
|
if (VideoUtils.isVideoThumbnailSupported(file)) {
|
||||||
if (openCVLoaded) {
|
if (openCVLoaded) {
|
||||||
updateMessage(Bundle.GetOrGenerateThumbnailTask_generatingPreviewFor(file.getName()));
|
updateMessage(Bundle.GetOrGenerateThumbnailTask_generatingPreviewFor(file.getName()));
|
||||||
thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize);
|
thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize);
|
||||||
} else if (defaultOnFailure) {
|
}
|
||||||
|
if (null == thumbnail) {
|
||||||
|
if (defaultOnFailure) {
|
||||||
thumbnail = DEFAULT_THUMBNAIL;
|
thumbnail = DEFAULT_THUMBNAIL;
|
||||||
} else {
|
} else {
|
||||||
throw new IIOException("Failed to read image for thumbnail generation.");
|
throw new IIOException("Failed to read image for thumbnail generation.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//read the image into a buffered image.
|
//read the image into a buffered image.
|
||||||
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null);
|
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null);
|
||||||
@ -717,9 +725,10 @@ public class ImageUtils {
|
|||||||
updateProgress(-1, 1);
|
updateProgress(-1, 1);
|
||||||
|
|
||||||
//if we got a valid thumbnail save it
|
//if we got a valid thumbnail save it
|
||||||
if (cacheFile != null && nonNull(thumbnail) && DEFAULT_THUMBNAIL != thumbnail) {
|
if ((cacheFile != null) && nonNull(thumbnail) && DEFAULT_THUMBNAIL != thumbnail) {
|
||||||
saveThumbnail(thumbnail);
|
saveThumbnail(thumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SwingFXUtils.toFXImage(thumbnail, null);
|
return SwingFXUtils.toFXImage(thumbnail, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,6 +884,7 @@ public class ImageUtils {
|
|||||||
protected void failed() {
|
protected void failed() {
|
||||||
super.failed();
|
super.failed();
|
||||||
LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file));
|
LOGGER.log(Level.WARNING, IMAGE_IO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file));
|
||||||
|
// Exceptions.printStackTrace(getException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,8 +43,8 @@ import org.sleuthkit.datamodel.AbstractFile;
|
|||||||
*/
|
*/
|
||||||
public class VideoUtils {
|
public class VideoUtils {
|
||||||
|
|
||||||
private static final List<String> SUPPORTED_VIDEO_EXTENSIONS
|
private static final List<String> SUPPORTED_VIDEO_EXTENSIONS =
|
||||||
= Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg",
|
Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg",
|
||||||
"mpeg", "asf", "divx", "rm", "moov", "wmv", "vob", "dat",
|
"mpeg", "asf", "divx", "rm", "moov", "wmv", "vob", "dat",
|
||||||
"m1v", "m2v", "m4v", "mkv", "mpe", "yop", "vqa", "xmv",
|
"m1v", "m2v", "m4v", "mkv", "mpe", "yop", "vqa", "xmv",
|
||||||
"mve", "wtv", "webm", "vivo", "vc1", "seq", "thp", "san",
|
"mve", "wtv", "webm", "vivo", "vc1", "seq", "thp", "san",
|
||||||
@ -58,7 +58,7 @@ public class VideoUtils {
|
|||||||
"flm", "tmv", "4xm"); //NON-NLS
|
"flm", "tmv", "4xm"); //NON-NLS
|
||||||
|
|
||||||
private static final SortedSet<String> SUPPORTED_VIDEO_MIME_TYPES = new TreeSet<>(
|
private static final SortedSet<String> SUPPORTED_VIDEO_MIME_TYPES = new TreeSet<>(
|
||||||
Arrays.asList("application/x-shockwave-flash", "video/x-m4v", "video/quicktime", "video/avi", "video/msvideo", "video/x-msvideo",
|
Arrays.asList("application/x-shockwave-flash", "video/x-m4v", "video/x-flv", "video/quicktime", "video/avi", "video/msvideo", "video/x-msvideo",
|
||||||
"video/mp4", "video/x-ms-wmv", "video/mpeg", "video/asf")); //NON-NLS
|
"video/mp4", "video/x-ms-wmv", "video/mpeg", "video/asf")); //NON-NLS
|
||||||
|
|
||||||
private static final List<String> CONDITIONAL_MIME_TYPES = Arrays.asList("application/octet-stream");
|
private static final List<String> CONDITIONAL_MIME_TYPES = Arrays.asList("application/octet-stream");
|
||||||
@ -160,6 +160,6 @@ public class VideoUtils {
|
|||||||
|
|
||||||
videoFile.release(); // close the file
|
videoFile.release(); // close the file
|
||||||
|
|
||||||
return bufferedImage == null ? bufferedImage : ScalrWrapper.resizeFast(bufferedImage, iconSize);
|
return bufferedImage == null ? null : ScalrWrapper.resizeFast(bufferedImage, iconSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user