本文整理匯總了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;
}