在java中使用imgscalr调整肖像图像大小,但最终输出是风景。如何保证其保持同一方向?
我正在使用 imgscalr 在 Grails 应用程序中创建缩放图像。这是代码:
BufferedImage sourceImg = ImageIO.read(new File("/tmp" + File.separator + filename))
BufferedImage destImg = null
if(sourceImg.height >= sourceImg.width){
destImg = Scalr.resize(sourceImg, Scalr.Method.AUTOMATIC, Scalr.Mode.FIT_TO_HEIGHT, 800)
}
else{
destImg = Scalr.resize(sourceImg, Scalr.Method.AUTOMATIC, Scalr.Mode.FIT_TO_WIDTH, 800)
}
File newFile = new File("/tmp/processed" + File.separator + filename)
String formatName = foto.nomeArquivo.substring(foto.nomeArquivo.lastIndexOf('.')+1);
ImageIO.write(imgDestino, formatName.toUpperCase(), newFile)
到目前为止,请不要介意 formatName...我仍在测试 imgscalr 库。
我所有的图像都以横向结束。我正在 Mac 操作系统中进行开发。
谢谢
I am using imgscalr to create scale my images in a Grails application. Here is the code:
BufferedImage sourceImg = ImageIO.read(new File("/tmp" + File.separator + filename))
BufferedImage destImg = null
if(sourceImg.height >= sourceImg.width){
destImg = Scalr.resize(sourceImg, Scalr.Method.AUTOMATIC, Scalr.Mode.FIT_TO_HEIGHT, 800)
}
else{
destImg = Scalr.resize(sourceImg, Scalr.Method.AUTOMATIC, Scalr.Mode.FIT_TO_WIDTH, 800)
}
File newFile = new File("/tmp/processed" + File.separator + filename)
String formatName = foto.nomeArquivo.substring(foto.nomeArquivo.lastIndexOf('.')+1);
ImageIO.write(imgDestino, formatName.toUpperCase(), newFile)
Please do not mind about formatName so far.... I am still testing the imgscalr library.
All my images end in landscape orientation. I am developing in a Mac OS.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论