本文整理汇总了Java中com.mullassery.imaging.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于com.mullassery.imaging.util包,在下文中一共展示了Util类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resizeGivenMaxDimensions
import com.mullassery.imaging.util.Util; //导入依赖的package包/类
/**
* Resizes the given image to a maximum according to the given dimensions, returning the file where it is stored
*/
public static File resizeGivenMaxDimensions(final BufferedImage image, String contentType, final Dimensions maxDimensions) throws IOException, FileNotFoundException {
final Dimensions originalDimensions = new Dimensions(image.getWidth(), image.getHeight());
if ((ImageHelper.ImageType.getByContentType(contentType) == ImageHelper.ImageType.GIF)) {
contentType = "image/png";
}
// Resize the image and write it to disk
final Dimensions newDimensions = originalDimensions.resizeKeepingRatio(maxDimensions);
final BufferedImage thumbnail = imaging().resize(image, newDimensions.getWidth(), newDimensions.getHeight());
final File thumbFile = File.createTempFile("cyclos", "image");
Util.saveImage(imaging, thumbnail, ImageType.getByContentType(contentType).name(), thumbFile);
return thumbFile;
}