是否有任何opnesource java库可以调整大小以及增强任何类型的图像(jpg,jpeg,png,PNG都是精确的)?
答案 0 :(得分:1)
要重新调整图像大小,可以使用Java库javax.imageio
示例代码为
BufferedImage createResizedCopy(Image originalImage,
int scaledWidth, int scaledHeight,
boolean preserveAlpha)
{
System.out.println("resizing...");
int imageType = preserveAlpha ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
BufferedImage scaledBI = new BufferedImage(scaledWidth, scaledHeight, imageType);
Graphics2D g = scaledBI.createGraphics();
if (preserveAlpha) {
g.setComposite(AlphaComposite.Src);
}
g.drawImage(originalImage, 0, 0, scaledWidth, scaledHeight, null);
g.dispose();
return scaledBI;
}
使用此功能运行应用的示例是Example for image re-sizing using Java
您可以将任何图片网址作为?url和?height,?width。
传递答案 1 :(得分:0)
答案 2 :(得分:0)
检查Scalr:
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/
轻松调整图片大小:
Scalr.resize(img, maxWidth, maxHeight, (BufferedImageOp) null);