Search in sources :

Example 1 with TFileOutputStream

use of net.java.truevfs.access.TFileOutputStream in project mage by magefree.

the class ImageCache method makeThumbnail.

public static BufferedImage makeThumbnail(BufferedImage original, String path) {
    BufferedImage image = TransformedImageCache.getResizedImage(original, Constants.THUMBNAIL_SIZE_FULL.width, Constants.THUMBNAIL_SIZE_FULL.height);
    TFile imageFile = getTFile(path);
    if (imageFile == null) {
        return null;
    }
    try {
        try (TFileOutputStream outputStream = new TFileOutputStream(imageFile)) {
            String format = image.getColorModel().getNumComponents() > 3 ? "png" : "jpg";
            ImageIO.write(image, format, outputStream);
        }
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
        imageFile.delete();
    }
    return image;
}
Also used : TFile(net.java.truevfs.access.TFile) TFileOutputStream(net.java.truevfs.access.TFileOutputStream) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 TFile (net.java.truevfs.access.TFile)1 TFileOutputStream (net.java.truevfs.access.TFileOutputStream)1