Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | List of all members
org.sleuthkit.autopsy.coreutils.ImageUtils Class Reference

Classes

class  GetThumbnailTask
 
interface  PropertyExtractor
 
class  ReadImageTask
 
class  ReadImageTaskBase
 

Static Public Member Functions

static File getCachedThumbnailFile (Content content, int iconSize)
 
static Image getDefaultIcon ()
 
static Image getDefaultThumbnail ()
 
static File getFile (long id)
 
static BufferedImage getIcon (Content content, int iconSize)
 
static File getIconFile (Content content, int iconSize)
 
static int getImageHeight (AbstractFile file) throws IOException
 
static int getImageWidth (AbstractFile file) throws IOException
 
static List< String > getSupportedImageExtensions ()
 
static SortedSet< String > getSupportedImageMimeTypes ()
 
static BufferedImage getThumbnail (Content content, int iconSize)
 
static boolean hasImageFileHeader (AbstractFile file)
 
static boolean isGIF (AbstractFile file)
 
static boolean isImageThumbnailSupported (AbstractFile file)
 
static boolean isJpegFileHeader (AbstractFile file)
 
static boolean isPngFileHeader (AbstractFile file)
 
static Task< javafx.scene.image.Image > newGetThumbnailTask (AbstractFile file, int iconSize, boolean defaultOnFailure)
 
static Task< javafx.scene.image.Image > newReadImageTask (AbstractFile file)
 
static boolean thumbnailSupported (Content content)
 

Static Public Attributes

static final int ICON_SIZE_LARGE = 200
 
static final int ICON_SIZE_MEDIUM = 100
 
static final int ICON_SIZE_SMALL = 50
 

Static Private Member Functions

static BufferedInputStream getBufferedReadContentStream (AbstractFile file)
 
static File getCachedThumbnailLocation (long fileID)
 
synchronized static FileTypeDetector getFileTypeDetector () throws FileTypeDetector.FileTypeDetectorInitException
 
static< T > T getImageProperty (AbstractFile file, final String errorTemplate, PropertyExtractor< T > propertyExtractor) throws IOException
 
static long getJfifStartOfImageOffset (AbstractFile file)
 
static byte[] readHeader (AbstractFile file, int buffLength) throws TskCoreException
 

Static Private Attributes

static final ConcurrentHashMap< Long, File > cacheFileMap = new ConcurrentHashMap<>()
 
static final BufferedImage DEFAULT_THUMBNAIL
 
static final boolean FFMPEG_LOADED
 
static FileTypeDetector fileTypeDetector
 
static final String FORMAT = "png"
 
static final List< String > GIF_EXTENSION_LIST = Arrays.asList("gif")
 
static final SortedSet< String > GIF_MIME_SET = ImmutableSortedSet.copyOf(new String[]{"image/gif"})
 
static final Executor imageSaver
 
static final Logger LOGGER = Logger.getLogger(ImageUtils.class.getName())
 
static final List< String > SUPPORTED_IMAGE_EXTENSIONS = new ArrayList<>()
 
static final SortedSet< String > SUPPORTED_IMAGE_MIME_TYPES
 

Detailed Description

Utilities for working with image files and creating thumbnails. Re-uses thumbnails by storing them in the case's cache directory.

Definition at line 79 of file ImageUtils.java.

Member Function Documentation

static BufferedInputStream org.sleuthkit.autopsy.coreutils.ImageUtils.getBufferedReadContentStream ( AbstractFile  file)
staticprivate

Get a BufferedInputStream wrapped around a ReadContentStream for the given AbstractFile.

Parameters
fileThe AbstractFile to get a stream for.
Returns
A BufferedInputStream wrapped around a ReadContentStream for the given AbstractFile

Definition at line 380 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getImageProperty(), org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail(), and org.sleuthkit.autopsy.coreutils.ImageUtils.ReadImageTaskBase.readImage().

static File org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailFile ( Content  content,
int  iconSize 
)
static

Get a thumbnail of a specified size for the given image. Generates the thumbnail if it is not already cached.

Parameters
contentthe content to generate a thumbnail for
iconSizethe size (one side of a square) in pixels to generate
Returns
File object for cached image. Is guaranteed to exist, as long as there was not an error generating or saving the thumbnail.

Definition at line 395 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailLocation(), and org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getIconFile().

static File org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailLocation ( long  fileID)
staticprivate

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.

Parameters
fileIDthe fileID to get the cached thumbnail location for
Returns
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.

Definition at line 410 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.cacheFileMap, org.sleuthkit.autopsy.casemodule.Case.getCacheDirectory(), and org.sleuthkit.autopsy.casemodule.Case.getCurrentCaseThrows().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailFile(), org.sleuthkit.autopsy.coreutils.ImageUtils.getFile(), and org.sleuthkit.autopsy.coreutils.ImageUtils.GetThumbnailTask.GetThumbnailTask().

static Image org.sleuthkit.autopsy.coreutils.ImageUtils.getDefaultIcon ( )
static

Get the default thumbnail, which is the icon for a file. Used when we can not generate content based thumbnail.

Returns
Deprecated:
use getDefaultThumbnail() instead.

Definition at line 1017 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getDefaultThumbnail().

static Image org.sleuthkit.autopsy.coreutils.ImageUtils.getDefaultThumbnail ( )
static

Get the default thumbnail, which is the icon for a file. Used when we can not generate a content based thumbnail.

Returns
the default thumbnail

Definition at line 187 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.DEFAULT_THUMBNAIL.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getDefaultIcon(), and org.sleuthkit.autopsy.corecomponents.ThumbnailViewChildren.ThumbnailViewNode.getIcon().

static File org.sleuthkit.autopsy.coreutils.ImageUtils.getFile ( long  id)
static

Get a file object for where the cached icon should exist. The returned file may not exist.

Parameters
id
Returns
Deprecated:
use getCachedThumbnailLocation(long) instead

Definition at line 1033 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailLocation().

synchronized static FileTypeDetector org.sleuthkit.autopsy.coreutils.ImageUtils.getFileTypeDetector ( ) throws FileTypeDetector.FileTypeDetectorInitException
staticprivate

//TODO: AUT-2057 this FileTypeDetector needs to be recreated when the user adds new user defined file types.

get a FileTypeDetector

Returns
a FileTypeDetector
Exceptions
FileTypeDetectorInitExceptionif initializing the FileTypeDetector failed.

Definition at line 315 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.fileTypeDetector.

static BufferedImage org.sleuthkit.autopsy.coreutils.ImageUtils.getIcon ( Content  content,
int  iconSize 
)
static

Get a thumbnail of a specified size for the given image. Generates the thumbnail if it is not already cached.

Parameters
content
iconSize
Returns
a thumbnail for the given image or a default one if there was a problem making a thumbnail.
Deprecated:
use getThumbnail(org.sleuthkit.datamodel.Content, int) instead.

Definition at line 1052 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail().

static File org.sleuthkit.autopsy.coreutils.ImageUtils.getIconFile ( Content  content,
int  iconSize 
)
static

Get a thumbnail of a specified size for the given image. Generates the thumbnail if it is not already cached.

Parameters
content
iconSize
Returns
File object for cached image. Is guaranteed to exist, as long as there was not an error generating or saving the thumbnail.
Deprecated:
use getCachedThumbnailFile(org.sleuthkit.datamodel.Content, int) instead.

Definition at line 1072 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailFile().

static int org.sleuthkit.autopsy.coreutils.ImageUtils.getImageHeight ( AbstractFile  file) throws IOException
static

Get the height of the given image,in pixels.

Parameters
file
Returns
the height in pixels
Exceptions
IOExceptionIf the file is not a supported image or the height could not be determined.

Definition at line 565 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getImageProperty().

static <T> T org.sleuthkit.autopsy.coreutils.ImageUtils.getImageProperty ( AbstractFile  file,
final String  errorTemplate,
PropertyExtractor< T >  propertyExtractor 
) throws IOException
staticprivate

Private template method designed to be used as the implementation of public methods that pull particular (usually meta-)data out of a image file.

Parameters
filethe file to extract the data from
errorTemplatea message template used to log errors. Should take one parameter: the file's unique path or name.
propertyExtractoran implementation of PropertyExtractor used to retrieve the specific property.
Returns
the the value of the property extracted by the given propertyExtractor
Exceptions
IOExceptionif there was a problem reading the property from the file.
See also
PropertyExtractor
getImageHeight(org.sleuthkit.datamodel.AbstractFile)

Definition at line 608 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getBufferedReadContentStream().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getImageHeight(), org.sleuthkit.autopsy.coreutils.ImageUtils.getImageWidth(), and org.sleuthkit.autopsy.coreutils.ImageUtils.ReadImageTaskBase.readImage().

static int org.sleuthkit.autopsy.coreutils.ImageUtils.getImageWidth ( AbstractFile  file) throws IOException
static

Get the width of the given image, in pixels.

Parameters
file
Returns
the width in pixels
Exceptions
IOExceptionIf the file is not a supported image or the width could not be determined.

Definition at line 548 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.getImageProperty().

static long org.sleuthkit.autopsy.coreutils.ImageUtils.getJfifStartOfImageOffset ( AbstractFile  file)
staticprivate

Find the offset for the first Start Of Image marker (0xFFD8) in JFIF, allowing for leading End Of Image markers.

Parameters
filethe AbstractFile to parse
Returns
Offset of first Start Of Image marker, or 0 if none found. This will let ImageIO try to open it from offset 0.

Definition at line 468 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.readHeader().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.ReadImageTaskBase.readImage().

static List<String> org.sleuthkit.autopsy.coreutils.ImageUtils.getSupportedImageExtensions ( )
static

Definition at line 173 of file ImageUtils.java.

static SortedSet<String> org.sleuthkit.autopsy.coreutils.ImageUtils.getSupportedImageMimeTypes ( )
static

Definition at line 177 of file ImageUtils.java.

static BufferedImage org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail ( Content  content,
int  iconSize 
)
static

Get a thumbnail of a specified size for the given image. Generates the thumbnail if it is not already cached.

Parameters
contentthe content to generate a thumbnail for
iconSizethe size (one side of a square) in pixels to generate
Returns
A thumbnail for the given image or a default one if there was a problem making a thumbnail.

Definition at line 332 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.DEFAULT_THUMBNAIL, org.sleuthkit.autopsy.coreutils.ImageUtils.getBufferedReadContentStream(), org.sleuthkit.autopsy.coreutils.ImageUtils.isGIF(), org.sleuthkit.autopsy.coreutils.ImageUtils.newGetThumbnailTask(), and org.sleuthkit.autopsy.corelibs.ScalrWrapper.resizeHighQuality().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailFile(), and org.sleuthkit.autopsy.coreutils.ImageUtils.getIcon().

static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.hasImageFileHeader ( AbstractFile  file)
static

Do a direct check to see if the given file has an image file header. NOTE: Currently only jpeg and png are supported.

Parameters
filethe AbstractFile to check
Returns
true if the given file has one of the supported image headers.

Definition at line 430 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.isJpegFileHeader(), and org.sleuthkit.autopsy.coreutils.ImageUtils.isPngFileHeader().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.isImageThumbnailSupported().

static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.isGIF ( AbstractFile  file)
static

Checks the MIME type and/or extension of a file to determine whether it is a GIF.

Parameters
filethe AbstractFile to test
Returns
true if the file is a gif

Definition at line 244 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.GetThumbnailTask.call(), org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail(), and org.sleuthkit.autopsy.coreutils.ImageUtils.ReadImageTaskBase.readImage().

static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.isImageThumbnailSupported ( AbstractFile  file)
static

Is the file an image that we can read and generate a thumbnail for?

Parameters
filethe AbstractFile to test
Returns
true if the file is an image we can read and generate thumbnail for.

Definition at line 232 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.hasImageFileHeader().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.thumbnailSupported().

static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.isJpegFileHeader ( AbstractFile  file)
static

Check if the given file is a jpeg based on header.

Parameters
filethe AbstractFile to check
Returns
true if jpeg file, false otherwise

Definition at line 441 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.readHeader().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.hasImageFileHeader().

static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.isPngFileHeader ( AbstractFile  file)
static

Check if the given file is a png based on header.

Parameters
filethe AbstractFile to check
Returns
true if png file, false otherwise

Definition at line 505 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.readHeader().

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.hasImageFileHeader().

static Task<javafx.scene.image.Image> org.sleuthkit.autopsy.coreutils.ImageUtils.newGetThumbnailTask ( AbstractFile  file,
int  iconSize,
boolean  defaultOnFailure 
)
static

Create a new Task that will get a thumbnail for the given image of the specified size. If a cached thumbnail is available it will be returned as the result of the task, otherwise a new thumbnail will be created and cached.

Note: the returned task is suitable for running in a background thread, but is not started automatically. Clients are responsible for running the task, monitoring its progress, and using its result.

Parameters
fileThe file to create a thumbnail for.
iconSizeThe size of the thumbnail.
defaultOnFailureWhether or not to default on failure.
Returns
a new Task that returns a thumbnail as its result.

Definition at line 653 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getThumbnail().

static Task<javafx.scene.image.Image> org.sleuthkit.autopsy.coreutils.ImageUtils.newReadImageTask ( AbstractFile  file)
static

Create a new Task that will read the file into memory as an javafx.scene.image.Image.

Note: the returned task is suitable for running in a background thread, but is not started automatically. Clients are responsible for running the task, monitoring its progress, and using its result(including testing for null).

Parameters
filethe file to read as an Image
Returns
a new Task that returns an Image as its result

Definition at line 827 of file ImageUtils.java.

static byte [] org.sleuthkit.autopsy.coreutils.ImageUtils.readHeader ( AbstractFile  file,
int  buffLength 
) throws TskCoreException
staticprivate
static boolean org.sleuthkit.autopsy.coreutils.ImageUtils.thumbnailSupported ( Content  content)
static

Can a thumbnail be generated for the content?

Although this method accepts Content, it always returns false for objects that are not instances of AbstractFile.

Parameters
contentA content object to test for thumbnail support.
Returns
true if a thumbnail can be generated for the given content.

Before taking on the potentially costly task of calculating the MIME type that can happen in isMediaThumbnailSupported() below, let's first see if the file extension is in the set of supported media file extensions.

Definition at line 201 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.VideoUtils.getSupportedVideoExtensions(), org.sleuthkit.autopsy.coreutils.ImageUtils.isImageThumbnailSupported(), org.sleuthkit.autopsy.coreutils.VideoUtils.isVideoThumbnailSupported(), and org.sleuthkit.autopsy.coreutils.ImageUtils.SUPPORTED_IMAGE_EXTENSIONS.

Member Data Documentation

final ConcurrentHashMap<Long, File> org.sleuthkit.autopsy.coreutils.ImageUtils.cacheFileMap = new ConcurrentHashMap<>()
staticprivate

Map from tsk object id to Java File object. Used to get the same File for different tasks related to the same object so we can then synchronize on the File.

NOTE: Must be cleared when the case is changed.

Definition at line 111 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getCachedThumbnailLocation().

final BufferedImage org.sleuthkit.autopsy.coreutils.ImageUtils.DEFAULT_THUMBNAIL
staticprivate
final boolean org.sleuthkit.autopsy.coreutils.ImageUtils.FFMPEG_LOADED
staticprivate

Definition at line 100 of file ImageUtils.java.

FileTypeDetector org.sleuthkit.autopsy.coreutils.ImageUtils.fileTypeDetector
staticprivate

initialized lazily

Definition at line 164 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.getFileTypeDetector().

final String org.sleuthkit.autopsy.coreutils.ImageUtils.FORMAT = "png"
staticprivate

save thumbnails to disk as this format

Definition at line 86 of file ImageUtils.java.

final List<String> org.sleuthkit.autopsy.coreutils.ImageUtils.GIF_EXTENSION_LIST = Arrays.asList("gif")
staticprivate

Definition at line 94 of file ImageUtils.java.

final SortedSet<String> org.sleuthkit.autopsy.coreutils.ImageUtils.GIF_MIME_SET = ImmutableSortedSet.copyOf(new String[]{"image/gif"})
staticprivate

Definition at line 95 of file ImageUtils.java.

final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_LARGE = 200
static
final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_MEDIUM = 100
static
final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_SMALL = 50
static
final Executor org.sleuthkit.autopsy.coreutils.ImageUtils.imageSaver
staticprivate
Initial value:
= Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder()
.namingPattern("thumbnail-saver-%d").build())

Thread/Executor that saves generated thumbnails to disk in the background

Definition at line 170 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.GetThumbnailTask.saveThumbnail().

final Logger org.sleuthkit.autopsy.coreutils.ImageUtils.LOGGER = Logger.getLogger(ImageUtils.class.getName())
staticprivate

Definition at line 81 of file ImageUtils.java.

final List<String> org.sleuthkit.autopsy.coreutils.ImageUtils.SUPPORTED_IMAGE_EXTENSIONS = new ArrayList<>()
staticprivate
final SortedSet<String> org.sleuthkit.autopsy.coreutils.ImageUtils.SUPPORTED_IMAGE_MIME_TYPES
staticprivate

Definition at line 98 of file ImageUtils.java.


The documentation for this class was generated from the following file:

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.