/** * Generate a Thumbnail of the input file. Try all available Thumbnailers and use the first that * returns an image. * * <p>MIME-Detection narrows the selection of Thumbnailers to try: * <li>First all Thumbnailers that declare to accept such a MIME Type are used * <li>Then all Thumbnailers that declare to accept all possible MIME Types. * * @param input Input file that should be processed * @param output File in which should be written * @param mimeType MIME-Type of input file (null if unknown) * @throws IOException If file cannot be read/written. * @throws ThumbnailerException If the thumbnailing process failed (i.e., no thumbnailer could * generate an Thumbnail. The last ThumbnailerException is re-thrown.) */ public void generateThumbnail(File input, File output, String mimeType) throws IOException, ThumbnailerException { FileDoesNotExistException.check(input, "The input file"); FileDoesNotExistException.checkWrite(output, "The output file", true, false); boolean generated = false; // MIME might be known already (in case of recursive thumbnail managers) if (mimeType == null) { mimeType = mimeTypeDetector.getMimeType(input); mLog.debug("Detected Mime-Typ: " + mimeType); } if (mimeType != null) generated = executeThumbnailers(mimeType, input, output, mimeType); // Try again using wildcard thumbnailers if (!generated) generated = executeThumbnailers(ALL_MIME_WILDCARD, input, output, mimeType); if (!generated) throw new ThumbnailerException( "No suitable Thumbnailer has been found. (File: " + input.getName() + " ; Detected MIME: " + mimeType + ")"); }