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;
}
Aggregations