鱼C论坛

 找回密码
 立即注册
查看: 2375|回复: 3

关于Thumbnails问题

[复制链接]
发表于 2019-8-31 13:26:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
public static void main(String[] args) throws IOException {
        Thumbnails.of(new File("G:\\images\\xiaohuangren.jpg")).
                size(200, 200)
                .watermark(Positions.BOTTOM_RIGHT, ImageIO.read(new File(basePath+"/watermark.jpg")), 0.25f)
                .outputQuality(0.8f).toFile("G:\\images\\xiaohuangrennew.jpg");

    }

报错信息:
/D:/IdeaProjects/o2o/target/classes/
Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageWriterSpi.onRegistration(WBMPImageWriterSpi.java:103)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.bmp.BMPImageWriterSpi.onRegistration(BMPImageWriterSpi.java:105)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.gif.GIFImageWriterSpi.onRegistration(GIFImageWriterSpi.java:140)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi.onRegistration(WBMPImageReaderSpi.java:96)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi.onRegistration(BMPImageReaderSpi.java:97)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-9-25 12:48:57 | 显示全部楼层
你的basePath是什么,检查下是否有错。
本地已执行你的代码,正确无误
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-9-25 12:49:38 | 显示全部楼层
minidog 发表于 2019-9-25 12:48
你的basePath是什么,检查下是否有错。
本地已执行你的代码,正确无误

附代码
public static void main(String[] args) throws IOException {
                Thumbnails.of(new File("G:\\images\\001.jpg")).size(200, 200)
                .watermark(Positions.BOTTOM_RIGHT, ImageIO.read(new File("G:\\images\\002.jpg")), 0.25f)
                .outputQuality(0.8f).toFile("G:\\images\\001.jpg");

    }
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-10-11 16:09:29 | 显示全部楼层
没用过Thumbnails

java.lang.NumberFormatException 是数值转换异常

java.lang.NumberFormatException: For input string: "" 意思是试图将空字符串转换为一个数值时发生错误

建议以debug的方式根据以下异常堆栈信息, 自下而上的调试源码
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:662)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
        at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageWriterSpi.onRegistration(WBMPImageWriterSpi.java:103)
        at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
        at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
        at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
        at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
        at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
        at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
        at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)

检查引的包是否有冲突, 引的包版本是否匹配

检查下你的图片是否有问题(不存在, 路径错误, 图片有问题, 无权限...)?


我能想到的排查思路就这些了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-15 15:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表