Autopsy  4.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 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 byte[] readHeader (AbstractFile file, int buffLength) throws TskCoreException
 

Static Private Attributes

static final BufferedImage DEFAULT_THUMBNAIL
 
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 boolean openCVLoaded
 
static final List< String > SUPPORTED_IMAGE_EXTENSIONS
 
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 74 of file ImageUtils.java.

Member Function Documentation

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 317 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 of the cached thumbnail for a file with the given fileID as a java File. 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 332 of file ImageUtils.java.

References org.sleuthkit.autopsy.casemodule.Case.getCacheDirectory(), and org.sleuthkit.autopsy.casemodule.Case.getCurrentCase().

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 857 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 168 of file ImageUtils.java.

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

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

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 873 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 271 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 892 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 912 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 446 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
<T>the type of the property to be retrieved.
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 489 of file ImageUtils.java.

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 429 of file ImageUtils.java.

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

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

Definition at line 154 of file ImageUtils.java.

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

Definition at line 158 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 288 of file ImageUtils.java.

References org.sleuthkit.autopsy.coreutils.ImageUtils.DEFAULT_THUMBNAIL, and org.sleuthkit.autopsy.coreutils.ImageUtils.newGetThumbnailTask().

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 350 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 213 of file ImageUtils.java.

Referenced by org.sleuthkit.autopsy.coreutils.ImageUtils.GetThumbnailTask.call(), 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 201 of file ImageUtils.java.

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

Referenced by org.sleuthkit.autopsy.corecomponents.MediaViewImagePanel.isSupported(), and 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 361 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 386 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 537 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 686 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.

Definition at line 182 of file ImageUtils.java.

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

Referenced by org.sleuthkit.autopsy.report.ReportGenerator.TableReportsWorker.checkIfFileIsImage().

Member Data Documentation

final BufferedImage org.sleuthkit.autopsy.coreutils.ImageUtils.DEFAULT_THUMBNAIL
staticprivate
FileTypeDetector org.sleuthkit.autopsy.coreutils.ImageUtils.fileTypeDetector
staticprivate

initialized lazily

Definition at line 145 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 81 of file ImageUtils.java.

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

Definition at line 89 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 90 of file ImageUtils.java.

final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_LARGE = 200
static

Definition at line 85 of file ImageUtils.java.

final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_MEDIUM = 100
static

Definition at line 84 of file ImageUtils.java.

final int org.sleuthkit.autopsy.coreutils.ImageUtils.ICON_SIZE_SMALL = 50
static

Definition at line 83 of file ImageUtils.java.

final Executor org.sleuthkit.autopsy.coreutils.ImageUtils.imageSaver
staticprivate
Initial value:
= Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder()
.namingPattern("thumbnail-saver-%d").build())

thread that saves generated thumbnails to disk in the background

Definition at line 151 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 76 of file ImageUtils.java.

final boolean org.sleuthkit.autopsy.coreutils.ImageUtils.openCVLoaded
staticprivate

Definition at line 95 of file ImageUtils.java.

final List<String> org.sleuthkit.autopsy.coreutils.ImageUtils.SUPPORTED_IMAGE_EXTENSIONS
staticprivate

Definition at line 92 of file ImageUtils.java.

final SortedSet<String> org.sleuthkit.autopsy.coreutils.ImageUtils.SUPPORTED_IMAGE_MIME_TYPES
staticprivate

Definition at line 93 of file ImageUtils.java.


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

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.