private AvatarImageDataProviderImpl(final InputStream uploadedImage, final Selection cropping) throws IOException { // rather should accept image? this.uploadedImage = thumber.getImage(uploadedImage); this.cropping = cropping; }
public Image getImageFromFile(final File sourceFile) throws IOException { Image sourceImage = thumber.getImage(sourceFile, Predicates.<ReusableBufferedInputStream>alwaysTrue()); if (sourceImage == null) { throw new IOException("invalid image format: " + sourceFile.getName()); } return sourceImage; }
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; }
/** * Reads an image from the specified input stream. * * @return An Image object or null if there was no suitable ImageReader for the given data */ public BufferedImage getImage(InputStream is) throws IOException { ReusableBufferedInputStream reusableInputStream = new ReusableBufferedInputStream(is); try { return getImage(reusableInputStream, Predicates.<ReusableBufferedInputStream>alwaysTrue()); } finally { reusableInputStream.destroy(); } }
/** * Retrieves an image for the specified file if the supplied predicate is met. * * @param file File to read an image from * @param predicate Predicate that needs to be met before attempting to read an image from the file (e.g. image * dimensions that shouldn't be exceeded) * @return An Image object or null if there was no suitable ImageReader for the given data * @throws FailedPredicateException If predicate was supplied but not met */ public BufferedImage getImage(File file, @Nonnull Predicate<ReusableBufferedInputStream> predicate) throws IOException { ReusableBufferedInputStream reusableInputStream = new ReusableBufferedInputStream(new FileInputStream(file)); try { return getImage(reusableInputStream, predicate); } finally { reusableInputStream.destroy(); } }
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); }
File processImage(final Avatar created, final InputStream imageData, final Selection croppingSelection, final ImageSize size) throws IOException { RenderedImage image = scaler.getSelectedImageData(new Thumber().getImage(imageData), croppingSelection, size.getPixels()); File file = createAvatarFile(created, size.getFilenameFlag()); avatarTagger.saveTaggedAvatar(image, AVATAR_IMAGE_FORMAT_FULL.getName(), file); eventPublisher.publish(new JiraHomeChangeEvent(JiraHomeChangeEvent.Action.FILE_ADD, JiraHomeChangeEvent.FileType.AVATAR, file)); return file; }
try sourceImage = thumber.getImage(sourceFile, Predicates.<ReusableBufferedInputStream>alwaysTrue());
try image = thumber.getImage(scaledFile.getResult(), Predicates.<ReusableBufferedInputStream>alwaysTrue());