experimental work to show mimetype icon for undisplayable images/videos
@ -182,6 +182,21 @@
|
||||
</dependency>
|
||||
</module-dependencies>
|
||||
<public-packages>
|
||||
<package>org.apache.tika</package>
|
||||
<package>org.apache.tika.config</package>
|
||||
<package>org.apache.tika.detect</package>
|
||||
<package>org.apache.tika.exception</package>
|
||||
<package>org.apache.tika.extractor</package>
|
||||
<package>org.apache.tika.fork</package>
|
||||
<package>org.apache.tika.io</package>
|
||||
<package>org.apache.tika.language</package>
|
||||
<package>org.apache.tika.metadata</package>
|
||||
<package>org.apache.tika.mime</package>
|
||||
<package>org.apache.tika.parser</package>
|
||||
<package>org.apache.tika.parser.external</package>
|
||||
<package>org.apache.tika.sax</package>
|
||||
<package>org.apache.tika.sax.xpath</package>
|
||||
<package>org.apache.tika.utils</package>
|
||||
<package>org.sleuthkit.autopsy.actions</package>
|
||||
<package>org.sleuthkit.autopsy.casemodule</package>
|
||||
<package>org.sleuthkit.autopsy.casemodule.services</package>
|
||||
|
@ -38,9 +38,9 @@ import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.Utilities;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.corelibs.ScalrWrapper;
|
||||
@ -99,6 +99,7 @@ public enum ThumbnailCache {
|
||||
* @return a thumbnail for the given file, returns null if the thumbnail
|
||||
* could not be generated
|
||||
*/
|
||||
@Nullable
|
||||
public Image get(DrawableFile<?> file) {
|
||||
try {
|
||||
return cache.get(file.getId(), () -> load(file)).orElse(null);
|
||||
@ -108,11 +109,12 @@ public enum ThumbnailCache {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Image get(Long fileID) {
|
||||
try {
|
||||
return get(ImageGalleryController.getDefault().getFileFromId(fileID));
|
||||
} catch (TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
LOGGER.log(Level.WARNING, "failed to load icon for file id : " + fileID, ex.getCause());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -181,6 +183,7 @@ public enum ThumbnailCache {
|
||||
* @return the newly generated thumbnail {@link Image}, or {@code null} if a
|
||||
* thumbnail could not be generated
|
||||
*/
|
||||
@Nullable
|
||||
private Image generateAndSaveThumbnail(final DrawableFile<?> file) {
|
||||
//create a buffered input stream for the underlying Abstractfile
|
||||
try (InputStream inputStream = new BufferedInputStream(new ReadContentInputStream(file.getAbstractFile()))) {
|
||||
@ -212,6 +215,7 @@ public enum ThumbnailCache {
|
||||
* @return a thumbnail generated for the given file, or {@code null} if a
|
||||
* thumbnail could not be generated
|
||||
*/
|
||||
@Nullable
|
||||
private Image fallbackToSwingImage(final DrawableFile<?> file) {
|
||||
final BufferedImage generateSwingIcon = generateSwingThumbnail(file);
|
||||
if (generateSwingIcon == null) { //if swing failed,
|
||||
|
@ -18,17 +18,16 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imagegallery.datamodel;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.logging.Level;
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import javafx.scene.image.Image;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tika.mime.MimeTypeException;
|
||||
import org.apache.tika.mime.MimeTypes;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.imagegallery.ThumbnailCache;
|
||||
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.ReadContentInputStream;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* ImageGallery data model object that represents an image file. It is a
|
||||
@ -51,24 +50,37 @@ public class ImageFile<T extends AbstractFile> extends DrawableFile<T> {
|
||||
return ThumbnailCache.getDefault().get(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Image getFullSizeImage() {
|
||||
Image image = null;
|
||||
if (imageRef != null) {
|
||||
image = imageRef.get();
|
||||
}
|
||||
|
||||
// if (imageRef != null) {
|
||||
// image = imageRef.get();
|
||||
// }
|
||||
// if (image == null) {
|
||||
//
|
||||
// try (ReadContentInputStream readContentInputStream = new ReadContentInputStream(this.getAbstractFile())) {
|
||||
// BufferedImage read = ImageIO.read(readContentInputStream);
|
||||
// image = SwingFXUtils.toFXImage(read, null);
|
||||
// } catch (IOException | NullPointerException ex) {
|
||||
// Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file" + getName());
|
||||
// return null;
|
||||
// }
|
||||
// imageRef = new SoftReference<>(image);
|
||||
// }
|
||||
if (image == null) {
|
||||
try {
|
||||
String fileType1 = new FileTypeDetector().getFileType(file);
|
||||
String extension = MimeTypes.getDefaultMimeTypes().forName(fileType1).getExtension();
|
||||
extension = StringUtils.strip(extension, ".");
|
||||
final String name = "/org/sleuthkit/autopsy/imagegallery/images/mimeTypes/" + extension + "-icon-128x128.png";
|
||||
System.out.println(name);
|
||||
final String toExternalForm = ImageFile.class.getResource(name).toExternalForm();
|
||||
return new Image(toExternalForm, true);
|
||||
|
||||
try (ReadContentInputStream readContentInputStream = new ReadContentInputStream(this.getAbstractFile())) {
|
||||
BufferedImage read = ImageIO.read(readContentInputStream);
|
||||
image = SwingFXUtils.toFXImage(read, null);
|
||||
} catch (IOException | NullPointerException ex) {
|
||||
Logger.getLogger(ImageFile.class.getName()).log(Level.WARNING, "unable to read file" + getName());
|
||||
return null;
|
||||
} catch (NullPointerException | FileTypeDetector.FileTypeDetectorInitException | TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
} catch (MimeTypeException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
}
|
||||
imageRef = new SoftReference<>(image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
@ -112,13 +112,13 @@ public class MediaControl extends BorderPane {
|
||||
return new MediaControl(new MediaPlayer(file.getMedia()), file);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(VideoFile.class.getName()).log(Level.WARNING, "failed to initialize MediaControl for file " + file.getName(), ex);
|
||||
return new Text(ex.getLocalizedMessage() + "\nSee the logs for details.");
|
||||
return new Text(ex.getLocalizedMessage() + "\nSee the logs for details.\n\nTry the \"Open In External Viewer\" action.");
|
||||
} catch (MediaException ex) {
|
||||
Logger.getLogger(VideoFile.class.getName()).log(Level.WARNING, ex.getType() + " Failed to initialize MediaControl for file " + file.getName(), ex);
|
||||
return new Text(ex.getType() + "\nSee the logs for details.");
|
||||
return new Text(ex.getType() + "\nSee the logs for details.\n\nTry the \"Open In External Viewer\" action.");
|
||||
} catch (OutOfMemoryError ex) {
|
||||
Logger.getLogger(VideoFile.class.getName()).log(Level.WARNING, "failed to initialize MediaControl for file " + file.getName(), ex);
|
||||
return new Text("There was a problem playing video file.\nSee the logs for details.");
|
||||
return new Text("There was a problem playing video file.\nSee the logs for details.\n\nTry the \"Open In External Viewer\" action.");
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 588 B |
After Width: | Height: | Size: 983 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 587 B |
After Width: | Height: | Size: 972 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 786 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 815 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 360 B |
After Width: | Height: | Size: 785 B |
After Width: | Height: | Size: 659 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 975 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |