private Thumbnail getThumbnail(File thumbnailFile, String filename, long thumbId) throws IOException { if (thumbnailFile.exists()) { final Image thumbImage = getImage(thumbnailFile, Predicates.<ReusableBufferedInputStream>alwaysTrue()); return new Thumbnail(thumbImage.getHeight(null), thumbImage.getWidth(null), filename, thumbId, mimeType); } return null; }
private Thumbnail getThumbnail(File thumbnailFile, String filename, long thumbId) throws IOException { if (thumbnailFile.exists()) { final Image thumbImage = getImage(thumbnailFile); return new Thumbnail(thumbImage.getHeight(null), thumbImage.getWidth(null), filename, thumbId); } return null; }
private Thumbnail createThumbnail(InputStream inputStream, File thumbnailFile, int maxWidth, int maxHeight, long thumbId, String fileName) throws IOException, ThumbnailRenderException { final BufferedImage thumbnailImage = scaleImage(maxWidth, maxHeight, inputStream); final int height = thumbnailImage.getHeight(); final int width = thumbnailImage.getWidth(); storeImage(thumbnailImage, thumbnailFile); return new Thumbnail(height, width, fileName, thumbId, mimeType); }
private Thumbnail createThumbnail(InputStream originalFile, File thumbnailFile, int maxWidth, int maxHeight, long thumbId, String fileName) throws IOException, FileNotFoundException { // Load original image. Image originalImage = getImage(originalFile); // Create scaled buffered image from original image. BufferedImage scaledImage = scaleImage(originalImage, maxWidth, maxHeight); int height = scaledImage.getHeight(); int width = scaledImage.getWidth(); storeImage(scaledImage, thumbnailFile); return new Thumbnail(height, width, fileName, thumbId); }
private Thumbnail readThumbnail(@Nonnull final Attachment attachment, @Nonnull final File thumbnailFile) { if (thumbnailFile.exists()) { log.debug("Thumbnail file '{}' already exists. Returning existing thumbnail.", thumbnailFile); InputStream inputStream = null; try { inputStream = new FileInputStream(thumbnailFile); final ThumbnailDimension thumbnailDimension = ThumbnailUtil.dimensionsForImage(inputStream); return new Thumbnail(thumbnailDimension.getHeight(), thumbnailDimension.getWidth(), thumbnailFile.getName(), attachment.getId(), MIME_TYPE); } catch (IOException asd) { log.debug("Unable to read image data from existing thumbnail file '{}'. Deleting this thumbnail.", thumbnailFile); deleteQuietly(thumbnailFile); } finally { closeQuietly(inputStream); } } return null; }
return new Thumbnail(thumbnail.getHeight(), thumbnail.getWidth(), thumbnailFile.getName(), attachment.getId(), thumbnail.getMimeType());