如何获取图像尺寸(宽度和高度)?
我是 grails 新手。我花了很多时间寻找使用 grails 的图像大小,但最终一无所获。 我想通过仅给出图像的路径来使用 grails 找到图像大小(宽度和高度)。可以使用grails吗?如果是,怎么办? 请建议我找到图像尺寸的简单方法。
提前致谢, 文卡特什
I am new to grails. I spent fare amount of time in search of finding the image size using grails but end up with nothing.
I want to find the image size (width and height) using grails by just giving path of the image. Is it possible using grails? if yes, how?
Please suggest me easy way to find the image size.
Thanks in advance,
Venkatesh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您在 C:\tmp 中有一个图像,这样就可以了:
ImageIO 还支持从 URL 读取: 查看 ImageIO javadoc
Supposing you have an image in C:\tmp, this would do it:
ImageIO also supports reading from a URL: see ImageIO javadoc
感谢 @Nicolas Modrzyk 的回答,我已经能够为 bash 写一篇文章了。
java -jar groovy-all.jar -e 'javax.imageio.ImageIO.read(new File(args[0])).with { println "width: $width, height: $height" }' -- fancyImage.jpg
Thanks to the answer of @Nicolas Modrzyk I have been able to write a one liner for the bash.
java -jar groovy-all.jar -e 'javax.imageio.ImageIO.read(new File(args[0])).with { println "width: $width, height: $height" }' -- fancyImage.jpg