Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ImageUtils.java
Go to the documentation of this file.
1  /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012-16 Basis Technology Corp.
5  *
6  * Copyright 2012 42six Solutions.
7  * Contact: aebadirad <at> 42six <dot> com
8  * Project Contact/Architect: carrier <at> sleuthkit <dot> org
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 package org.sleuthkit.autopsy.coreutils;
23 
24 import com.google.common.collect.ImmutableSortedSet;
25 import com.google.common.io.Files;
26 import java.awt.Image;
27 import java.awt.image.BufferedImage;
28 import java.io.BufferedInputStream;
29 import java.io.File;
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.nio.file.Paths;
33 import java.text.MessageFormat;
34 import java.util.Arrays;
35 import java.util.Collection;
36 import java.util.Collections;
37 import java.util.Iterator;
38 import java.util.List;
39 import static java.util.Objects.nonNull;
40 import java.util.SortedSet;
41 import java.util.TreeSet;
42 import java.util.concurrent.ExecutionException;
43 import java.util.concurrent.Executor;
44 import java.util.concurrent.Executors;
45 import java.util.logging.Level;
46 import javafx.concurrent.Task;
47 import javafx.embed.swing.SwingFXUtils;
48 import javax.annotation.Nonnull;
49 import javax.annotation.Nullable;
50 import javax.imageio.IIOException;
51 import javax.imageio.ImageIO;
52 import javax.imageio.ImageReadParam;
53 import javax.imageio.ImageReader;
54 import javax.imageio.event.IIOReadProgressListener;
55 import javax.imageio.stream.ImageInputStream;
56 import org.apache.commons.lang3.ObjectUtils;
57 import org.apache.commons.lang3.StringUtils;
58 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
59 import org.opencv.core.Core;
60 import org.openide.util.NbBundle;
65 import org.sleuthkit.datamodel.AbstractFile;
66 import org.sleuthkit.datamodel.Content;
67 import org.sleuthkit.datamodel.ReadContentInputStream;
68 import org.sleuthkit.datamodel.TskCoreException;
69 
74 public class ImageUtils {
75 
76  private static final Logger LOGGER = Logger.getLogger(ImageUtils.class.getName());
77 
81  private static final String FORMAT = "png"; //NON-NLS
82 
83  public static final int ICON_SIZE_SMALL = 50;
84  public static final int ICON_SIZE_MEDIUM = 100;
85  public static final int ICON_SIZE_LARGE = 200;
86 
87  private static final BufferedImage DEFAULT_THUMBNAIL;
88 
89  private static final List<String> GIF_EXTENSION_LIST = Arrays.asList("gif");
90  private static final SortedSet<String> GIF_MIME_SET = ImmutableSortedSet.copyOf(new String[]{"image/gif"});
91 
92  private static final List<String> SUPPORTED_IMAGE_EXTENSIONS;
93  private static final SortedSet<String> SUPPORTED_IMAGE_MIME_TYPES;
94 
95  private static final boolean openCVLoaded;
96 
97  static {
98  ImageIO.scanForPlugins();
99  BufferedImage tempImage;
100  try {
101  tempImage = ImageIO.read(ImageUtils.class.getResourceAsStream("/org/sleuthkit/autopsy/images/file-icon.png"));//NON-NLS
102  } catch (IOException ex) {
103  LOGGER.log(Level.SEVERE, "Failed to load default icon.", ex); //NON-NLS
104  tempImage = null;
105  }
106  DEFAULT_THUMBNAIL = tempImage;
107 
108  //load opencv libraries
109  boolean openCVLoadedTemp;
110  try {
111  System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
112  if (System.getProperty("os.arch").equals("amd64") || System.getProperty("os.arch").equals("x86_64")) { //NON-NLS
113  System.loadLibrary("opencv_ffmpeg248_64"); //NON-NLS
114  } else {
115  System.loadLibrary("opencv_ffmpeg248"); //NON-NLS
116  }
117 
118  openCVLoadedTemp = true;
119  } catch (UnsatisfiedLinkError e) {
120  openCVLoadedTemp = false;
121  LOGGER.log(Level.SEVERE, "OpenCV Native code library failed to load", e); //NON-NLS
122  //TODO: show warning bubble
123 
124  }
125 
126  openCVLoaded = openCVLoadedTemp;
127  SUPPORTED_IMAGE_EXTENSIONS = Arrays.asList(ImageIO.getReaderFileSuffixes());
128  SUPPORTED_IMAGE_MIME_TYPES = new TreeSet<>(Arrays.asList(ImageIO.getReaderMIMETypes()));
129  /*
130  * special cases and variants that we support, but don't get registered
131  * with ImageIO automatically
132  */
133  SUPPORTED_IMAGE_MIME_TYPES.addAll(Arrays.asList(
134  "image/x-rgb", //NON-NLS
135  "image/x-ms-bmp", //NON-NLS
136  "image/x-portable-graymap", //NON-NLS
137  "image/x-portable-bitmap", //NON-NLS
138  "application/x-123")); //TODO: is this correct? -jm //NON-NLS
139  SUPPORTED_IMAGE_MIME_TYPES.removeIf("application/octet-stream"::equals); //NON-NLS
140  }
141 
146 
150  private static final Executor imageSaver
151  = Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder()
152  .namingPattern("thumbnail-saver-%d").build()); //NON-NLS
153 
154  public static List<String> getSupportedImageExtensions() {
155  return Collections.unmodifiableList(SUPPORTED_IMAGE_EXTENSIONS);
156  }
157 
158  public static SortedSet<String> getSupportedImageMimeTypes() {
159  return Collections.unmodifiableSortedSet(SUPPORTED_IMAGE_MIME_TYPES);
160  }
161 
168  public static Image getDefaultThumbnail() {
169  return DEFAULT_THUMBNAIL;
170  }
171 
182  public static boolean thumbnailSupported(Content content) {
183 
184  if (!(content instanceof AbstractFile)) {
185  return false;
186  }
187  AbstractFile file = (AbstractFile) content;
188 
190  || isImageThumbnailSupported(file);
191  }
192 
201  public static boolean isImageThumbnailSupported(AbstractFile file) {
202  return isMediaThumbnailSupported(file, "image/", SUPPORTED_IMAGE_MIME_TYPES, SUPPORTED_IMAGE_EXTENSIONS) || hasImageFileHeader(file);//NON-NLS
203  }
204 
213  public static boolean isGIF(AbstractFile file) {
214  return isMediaThumbnailSupported(file, null, GIF_MIME_SET, GIF_EXTENSION_LIST);
215  }
216 
237  static boolean isMediaThumbnailSupported(AbstractFile file, String mimeTypePrefix, final Collection<String> supportedMimeTypes, final List<String> supportedExtension) {
238  if (false == file.isFile() || file.getSize() <= 0) {
239  return false;
240  }
241 
242  String extension = file.getNameExtension();
243 
244  if (StringUtils.isNotBlank(extension) && supportedExtension.contains(extension)) {
245  return true;
246  } else {
247  try {
248  String mimeType = getFileTypeDetector().detect(file);
249  if (StringUtils.isNotBlank(mimeTypePrefix) && mimeType.startsWith(mimeTypePrefix)) {
250  return true;
251  }
252  return supportedMimeTypes.contains(mimeType);
253  } catch (FileTypeDetectorInitException | TskCoreException ex) {
254  LOGGER.log(Level.SEVERE, "Error determining MIME type of " + getContentPathSafe(file), ex);//NON-NLS
255  return false;
256  }
257  }
258  }
259 
272  if (fileTypeDetector == null) {
273  fileTypeDetector = new FileTypeDetector();
274  }
275  return fileTypeDetector;
276  }
277 
288  public static BufferedImage getThumbnail(Content content, int iconSize) {
289  if (content instanceof AbstractFile) {
290  AbstractFile file = (AbstractFile) content;
291 
292  Task<javafx.scene.image.Image> thumbnailTask = newGetThumbnailTask(file, iconSize, true);
293  thumbnailTask.run();
294  try {
295  return SwingFXUtils.fromFXImage(thumbnailTask.get(), null);
296  } catch (InterruptedException | ExecutionException ex) {
297  LOGGER.log(Level.WARNING, "Failed to get thumbnail for {0}: " + ex.toString(), getContentPathSafe(content)); //NON-NLS
298  return DEFAULT_THUMBNAIL;
299  }
300  } else {
301  return DEFAULT_THUMBNAIL;
302  }
303  }
304 
316  @Nullable
317  public static File getCachedThumbnailFile(Content content, int iconSize) {
318  getThumbnail(content, iconSize);
319  return getCachedThumbnailLocation(content.getId());
320  }
321 
332  private static File getCachedThumbnailLocation(long fileID) {
333  try {
334  String cacheDirectory = Case.getCurrentCase().getCacheDirectory();
335  return Paths.get(cacheDirectory, "thumbnails", fileID + ".png").toFile(); //NON-NLS
336  } catch (IllegalStateException e) {
337  LOGGER.log(Level.WARNING, "Could not get cached thumbnail location. No case is open."); //NON-NLS
338  return null;
339  }
340  }
341 
350  public static boolean hasImageFileHeader(AbstractFile file) {
351  return isJpegFileHeader(file) || isPngFileHeader(file);
352  }
353 
361  public static boolean isJpegFileHeader(AbstractFile file) {
362  if (file.getSize() < 100) {
363  return false;
364  }
365 
366  try {
367  byte[] fileHeaderBuffer = readHeader(file, 2);
368  /*
369  * Check for the JPEG header. Since Java bytes are signed, we cast
370  * them to an int first.
371  */
372  return (((fileHeaderBuffer[0] & 0xff) == 0xff) && ((fileHeaderBuffer[1] & 0xff) == 0xd8));
373  } catch (TskCoreException ex) {
374  //ignore if can't read the first few bytes, not a JPEG
375  return false;
376  }
377  }
378 
386  public static boolean isPngFileHeader(AbstractFile file) {
387  if (file.getSize() < 10) {
388  return false;
389  }
390 
391  try {
392  byte[] fileHeaderBuffer = readHeader(file, 8);
393  /*
394  * Check for the png header. Since Java bytes are signed, we cast
395  * them to an int first.
396  */
397  return (((fileHeaderBuffer[1] & 0xff) == 0x50) && ((fileHeaderBuffer[2] & 0xff) == 0x4E)
398  && ((fileHeaderBuffer[3] & 0xff) == 0x47) && ((fileHeaderBuffer[4] & 0xff) == 0x0D)
399  && ((fileHeaderBuffer[5] & 0xff) == 0x0A) && ((fileHeaderBuffer[6] & 0xff) == 0x1A)
400  && ((fileHeaderBuffer[7] & 0xff) == 0x0A));
401 
402  } catch (TskCoreException ex) {
403  //ignore if can't read the first few bytes, not an png
404  return false;
405  }
406  }
407 
408  private static byte[] readHeader(AbstractFile file, int buffLength) throws TskCoreException {
409  byte[] fileHeaderBuffer = new byte[buffLength];
410  int bytesRead = file.read(fileHeaderBuffer, 0, buffLength);
411 
412  if (bytesRead != buffLength) {
413  //ignore if can't read the first few bytes, not an image
414  throw new TskCoreException("Could not read " + buffLength + " bytes from " + file.getName());//NON-NLS
415  }
416  return fileHeaderBuffer;
417  }
418 
429  static public int getImageWidth(AbstractFile file) throws IOException {
430  return getImageProperty(file,
431  "ImageIO could not determine width of {0}: ", //NON-NLS
432  imageReader -> imageReader.getWidth(0)
433  );
434  }
435 
446  static public int getImageHeight(AbstractFile file) throws IOException {
447  return getImageProperty(file,
448  "ImageIO could not determine height of {0}: ", //NON-NLS
449  imageReader -> imageReader.getHeight(0)
450  );
451  }
452 
461  @FunctionalInterface
462  private static interface PropertyExtractor<T> {
463 
464  public T extract(ImageReader reader) throws IOException;
465  }
466 
489  private static <T> T getImageProperty(AbstractFile file, final String errorTemplate, PropertyExtractor<T> propertyExtractor) throws IOException {
490  try (InputStream inputStream = new BufferedInputStream(new ReadContentInputStream(file));) {
491  try (ImageInputStream input = ImageIO.createImageInputStream(inputStream)) {
492  if (input == null) {
493  IIOException iioException = new IIOException("Could not create ImageInputStream.");
494  LOGGER.log(Level.WARNING, errorTemplate + iioException.toString(), getContentPathSafe(file));
495  throw iioException;
496  }
497  Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
498 
499  if (readers.hasNext()) {
500  ImageReader reader = readers.next();
501  reader.setInput(input);
502  try {
503 
504  return propertyExtractor.extract(reader);
505  } catch (IOException ex) {
506  LOGGER.log(Level.WARNING, errorTemplate + ex.toString(), getContentPathSafe(file));
507  throw ex;
508  } finally {
509  reader.dispose();
510  }
511  } else {
512  IIOException iioException = new IIOException("No ImageReader found.");
513  LOGGER.log(Level.WARNING, errorTemplate + iioException.toString(), getContentPathSafe(file));
514 
515  throw iioException;
516  }
517  }
518  }
519  }
520 
537  public static Task<javafx.scene.image.Image> newGetThumbnailTask(AbstractFile file, int iconSize, boolean defaultOnFailure) {
538  return new GetThumbnailTask(file, iconSize, defaultOnFailure);
539  }
540 
544  static private class GetThumbnailTask extends ReadImageTaskBase {
545 
546  private static final String FAILED_TO_READ_IMAGE_FOR_THUMBNAIL_GENERATION = "Failed to read {0} for thumbnail generation."; //NON-NLS
547 
548  private final int iconSize;
549  private final File cacheFile;
550  private final boolean defaultOnFailure;
551 
552  @NbBundle.Messages({"# {0} - file name",
553  "GetOrGenerateThumbnailTask.loadingThumbnailFor=Loading thumbnail for {0}",
554  "# {0} - file name",
555  "GetOrGenerateThumbnailTask.generatingPreviewFor=Generating preview for {0}"})
556  private GetThumbnailTask(AbstractFile file, int iconSize, boolean defaultOnFailure) {
557  super(file);
558  updateMessage(Bundle.GetOrGenerateThumbnailTask_loadingThumbnailFor(file.getName()));
559  this.iconSize = iconSize;
560  this.defaultOnFailure = defaultOnFailure;
561  this.cacheFile = getCachedThumbnailLocation(file.getId());
562  }
563 
564  @Override
565  protected javafx.scene.image.Image call() throws Exception {
566  if (isGIF(file)) {
567  return readImage();
568  }
569  if (isCancelled()) {
570  return null;
571  }
572  // If a thumbnail file is already saved locally, just read that.
573  if (cacheFile != null && cacheFile.exists()) {
574  try {
575  BufferedImage cachedThumbnail = ImageIO.read(cacheFile);
576  if (nonNull(cachedThumbnail) && cachedThumbnail.getWidth() == iconSize) {
577  return SwingFXUtils.toFXImage(cachedThumbnail, null);
578  }
579  } catch (Exception ex) {
580  LOGGER.log(Level.WARNING, "ImageIO had a problem reading the cached thumbnail for {0}: " + ex.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
581  cacheFile.delete(); //since we can't read the file we might as well delete it.
582  }
583  }
584 
585  if (isCancelled()) {
586  return null;
587  }
588 
589  //There was no correctly-sized cached thumbnail so make one.
590  BufferedImage thumbnail = null;
592  if (openCVLoaded) {
593  updateMessage(Bundle.GetOrGenerateThumbnailTask_generatingPreviewFor(file.getName()));
594  thumbnail = VideoUtils.generateVideoThumbnail(file, iconSize);
595  }
596  if (null == thumbnail) {
597  if (defaultOnFailure) {
598  thumbnail = DEFAULT_THUMBNAIL;
599  } else {
600  throw new IIOException("Failed to generate a thumbnail for " + getContentPathSafe(file));//NON-NLS
601  }
602  }
603 
604  } else {
605  //read the image into a buffered image.
606  //TODO: I don't like this, we just converted it from BufferedIamge to fx Image -jm
607  BufferedImage bufferedImage = SwingFXUtils.fromFXImage(readImage(), null);
608  if (null == bufferedImage) {
609  String msg = MessageFormat.format(FAILED_TO_READ_IMAGE_FOR_THUMBNAIL_GENERATION, getContentPathSafe(file));
610  LOGGER.log(Level.WARNING, msg);
611  throw new IIOException(msg);
612  }
613  updateProgress(-1, 1);
614 
615  //resize, or if that fails, crop it
616  try {
617  thumbnail = ScalrWrapper.resizeFast(bufferedImage, iconSize);
618  } catch (IllegalArgumentException | OutOfMemoryError e) {
619  // if resizing does not work due to extreme aspect ratio or oom, crop the image instead.
620  LOGGER.log(Level.WARNING, "Cropping {0}, because it could not be scaled: " + e.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
621 
622  final int height = bufferedImage.getHeight();
623  final int width = bufferedImage.getWidth();
624  if (iconSize < height || iconSize < width) {
625  final int cropHeight = Math.min(iconSize, height);
626  final int cropWidth = Math.min(iconSize, width);
627  try {
628  thumbnail = ScalrWrapper.cropImage(bufferedImage, cropWidth, cropHeight);
629  } catch (Exception cropException) {
630  LOGGER.log(Level.WARNING, "Could not crop {0}: " + cropException.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
631  }
632  }
633  } catch (Exception e) {
634  LOGGER.log(Level.WARNING, "Could not scale {0}: " + e.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
635  throw e;
636  }
637  }
638 
639  if (isCancelled()) {
640  return null;
641  }
642 
643  updateProgress(-1, 1);
644 
645  //if we got a valid thumbnail save it
646  if ((cacheFile != null) && thumbnail != null && DEFAULT_THUMBNAIL != thumbnail) {
647  saveThumbnail(thumbnail);
648  }
649 
650  return SwingFXUtils.toFXImage(thumbnail, null);
651  }
652 
658  private void saveThumbnail(BufferedImage thumbnail) {
659  imageSaver.execute(() -> {
660  try {
661  Files.createParentDirs(cacheFile);
662  if (cacheFile.exists()) {
663  cacheFile.delete();
664  }
665  ImageIO.write(thumbnail, FORMAT, cacheFile);
666  } catch (IllegalArgumentException | IOException ex) {
667  LOGGER.log(Level.WARNING, "Could not write thumbnail for {0}: " + ex.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
668  }
669  });
670  }
671  }
672 
686  public static Task<javafx.scene.image.Image> newReadImageTask(AbstractFile file) {
687  return new ReadImageTask(file);
688  }
689 
693  @NbBundle.Messages({
694  "# {0} - file name",
695  "ReadImageTask.mesageText=Reading image: {0}"})
696  static private class ReadImageTask extends ReadImageTaskBase {
697 
698  ReadImageTask(AbstractFile file) {
699  super(file);
700  updateMessage(Bundle.ReadImageTask_mesageText(file.getName()));
701  }
702 
703  @Override
704  protected javafx.scene.image.Image call() throws Exception {
705  return readImage();
706  }
707  }
708 
712  static private abstract class ReadImageTaskBase extends Task<javafx.scene.image.Image> implements IIOReadProgressListener {
713 
714  private static final String IMAGEIO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT = "ImageIO could not read {0}. It may be unsupported or corrupt"; //NON-NLS
715  final AbstractFile file;
716 // private ImageReader reader;
717 
718  ReadImageTaskBase(AbstractFile file) {
719  this.file = file;
720  }
721 
722  protected javafx.scene.image.Image readImage() throws IOException {
723  if (ImageUtils.isGIF(file)) {
724  //use JavaFX to directly read GIF to preserve potential animation
725  javafx.scene.image.Image image = new javafx.scene.image.Image(new BufferedInputStream(new ReadContentInputStream(file)));
726  if (image.isError() == false) {
727  return image;
728  }
729  //fall through to default image reading code if there was an error
730  }
731  if (isCancelled()) {
732  return null;
733  }
734 
735  return getImageProperty(file, "ImageIO could not read {0}: ",
736  imageReader -> {
737  imageReader.addIIOReadProgressListener(ReadImageTaskBase.this);
738  /*
739  * This is the important part, get or create a
740  * ImageReadParam, create a destination image to hold
741  * the decoded result, then pass that image with the
742  * param.
743  */
744  ImageReadParam param = imageReader.getDefaultReadParam();
745  BufferedImage bufferedImage = imageReader.getImageTypes(0).next().createBufferedImage(imageReader.getWidth(0), imageReader.getHeight(0));
746  param.setDestination(bufferedImage);
747  try {
748  bufferedImage = imageReader.read(0, param); //should always be same bufferedImage object
749  } catch (IOException iOException) {
750  LOGGER.log(Level.WARNING, IMAGEIO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + iOException.toString(), ImageUtils.getContentPathSafe(file)); //NON-NLS
751  } finally {
752  imageReader.removeIIOReadProgressListener(ReadImageTaskBase.this);
753  }
754  if (isCancelled()) {
755  return null;
756  }
757  return SwingFXUtils.toFXImage(bufferedImage, null);
758  });
759  }
760 
761  @Override
762  public void imageProgress(ImageReader reader, float percentageDone) {
763  //update this task with the progress reported by ImageReader.read
764  updateProgress(percentageDone, 100);
765  if (isCancelled()) {
766  reader.removeIIOReadProgressListener(this);
767  reader.abort();
768  reader.dispose();
769  }
770  }
771 
772  @Override
773  protected void succeeded() {
774  super.succeeded();
775  try {
776  javafx.scene.image.Image fxImage = get();
777  if (fxImage == null) {
778  LOGGER.log(Level.WARNING, IMAGEIO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT, ImageUtils.getContentPathSafe(file));
779  } else {
780  if (fxImage.isError()) {
781  //if there was somekind of error, log it
782  LOGGER.log(Level.WARNING, IMAGEIO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(fxImage.getException()), ImageUtils.getContentPathSafe(file));
783  }
784  }
785  } catch (InterruptedException | ExecutionException ex) {
786  failed();
787  }
788  }
789 
790  @Override
791  protected void failed() {
792  super.failed();
793  LOGGER.log(Level.WARNING, IMAGEIO_COULD_NOT_READ_UNSUPPORTE_OR_CORRUPT + ": " + ObjectUtils.toString(getException()), ImageUtils.getContentPathSafe(file));
794  }
795 
796  @Override
797  public void imageComplete(ImageReader source) {
798  updateProgress(100, 100);
799  }
800 
801  @Override
802  public void imageStarted(ImageReader source, int imageIndex) {
803  }
804 
805  @Override
806  public void sequenceStarted(ImageReader source, int minIndex) {
807  }
808 
809  @Override
810  public void sequenceComplete(ImageReader source) {
811  }
812 
813  @Override
814  public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {
815  }
816 
817  @Override
818  public void thumbnailProgress(ImageReader source, float percentageDone) {
819  }
820 
821  @Override
822  public void thumbnailComplete(ImageReader source) {
823  }
824 
825  @Override
826  public void readAborted(ImageReader source) {
827  }
828  }
829 
838  static String getContentPathSafe(Content content) {
839  try {
840  return content.getUniquePath();
841  } catch (TskCoreException tskCoreException) {
842  String contentName = content.getName();
843  LOGGER.log(Level.SEVERE, "Failed to get unique path for " + contentName, tskCoreException); //NON-NLS
844  return contentName;
845  }
846  }
847 
856  @Deprecated
857  public static Image getDefaultIcon() {
858  return getDefaultThumbnail();
859  }
860 
871  @Deprecated
872 
873  public static File getFile(long id) {
874  return getCachedThumbnailLocation(id);
875  }
876 
890  @Nonnull
891  @Deprecated
892  public static BufferedImage getIcon(Content content, int iconSize) {
893  return getThumbnail(content, iconSize);
894  }
895 
910  @Nullable
911  @Deprecated
912  public static File getIconFile(Content content, int iconSize) {
913  return getCachedThumbnailFile(content, iconSize);
914 
915  }
916 
917 }
static File getIconFile(Content content, int iconSize)
static boolean isGIF(AbstractFile file)
static final List< String > SUPPORTED_IMAGE_EXTENSIONS
Definition: ImageUtils.java:92
static boolean isPngFileHeader(AbstractFile file)
static boolean thumbnailSupported(Content content)
void imageProgress(ImageReader reader, float percentageDone)
static Task< javafx.scene.image.Image > newGetThumbnailTask(AbstractFile file, int iconSize, boolean defaultOnFailure)
void imageStarted(ImageReader source, int imageIndex)
static synchronized BufferedImage resizeFast(BufferedImage input, int size)
static FileTypeDetector fileTypeDetector
static final SortedSet< String > GIF_MIME_SET
Definition: ImageUtils.java:90
static Task< javafx.scene.image.Image > newReadImageTask(AbstractFile file)
void sequenceStarted(ImageReader source, int minIndex)
static boolean isJpegFileHeader(AbstractFile file)
void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex)
GetThumbnailTask(AbstractFile file, int iconSize, boolean defaultOnFailure)
static int getImageHeight(AbstractFile file)
void thumbnailProgress(ImageReader source, float percentageDone)
static List< String > getSupportedImageExtensions()
static final BufferedImage DEFAULT_THUMBNAIL
Definition: ImageUtils.java:87
static File getCachedThumbnailFile(Content content, int iconSize)
static boolean hasImageFileHeader(AbstractFile file)
static byte[] readHeader(AbstractFile file, int buffLength)
static File getCachedThumbnailLocation(long fileID)
synchronized static Logger getLogger(String name)
Definition: Logger.java:166
static int getImageWidth(AbstractFile file)
static< T > T getImageProperty(AbstractFile file, final String errorTemplate, PropertyExtractor< T > propertyExtractor)
static boolean isImageThumbnailSupported(AbstractFile file)
static BufferedImage getThumbnail(Content content, int iconSize)
static final List< String > GIF_EXTENSION_LIST
Definition: ImageUtils.java:89
synchronized static FileTypeDetector getFileTypeDetector()
static BufferedImage getIcon(Content content, int iconSize)
static boolean isVideoThumbnailSupported(AbstractFile file)
Definition: VideoUtils.java:98
static final SortedSet< String > SUPPORTED_IMAGE_MIME_TYPES
Definition: ImageUtils.java:93
static synchronized BufferedImage cropImage(BufferedImage input, int width, int height)
static SortedSet< String > getSupportedImageMimeTypes()

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.