鱼C论坛

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

关于Thumbnails问题

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

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

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

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

  6.     }
复制代码


报错信息:
  1. /D:/IdeaProjects/o2o/target/classes/
  2. Caught and handled this exception :
  3. java.lang.NumberFormatException: For input string: ""
  4.         at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  5.         at java.base/java.lang.Integer.parseInt(Integer.java:662)
  6.         at java.base/java.lang.Integer.parseInt(Integer.java:770)
  7.         at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
  8.         at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageWriterSpi.onRegistration(WBMPImageWriterSpi.java:103)
  9.         at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
  10.         at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
  11.         at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
  12.         at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
  13.         at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
  14.         at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
  15.         at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
  16. Caught and handled this exception :
  17. java.lang.NumberFormatException: For input string: ""
  18.         at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  19.         at java.base/java.lang.Integer.parseInt(Integer.java:662)
  20.         at java.base/java.lang.Integer.parseInt(Integer.java:770)
  21.         at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
  22.         at com.github.jaiimageio.impl.plugins.bmp.BMPImageWriterSpi.onRegistration(BMPImageWriterSpi.java:105)
  23.         at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
  24.         at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
  25.         at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
  26.         at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
  27.         at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
  28.         at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
  29.         at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
  30. Caught and handled this exception :
  31. java.lang.NumberFormatException: For input string: ""
  32.         at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  33.         at java.base/java.lang.Integer.parseInt(Integer.java:662)
  34.         at java.base/java.lang.Integer.parseInt(Integer.java:770)
  35.         at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
  36.         at com.github.jaiimageio.impl.plugins.gif.GIFImageWriterSpi.onRegistration(GIFImageWriterSpi.java:140)
  37.         at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
  38.         at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
  39.         at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
  40.         at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
  41.         at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
  42.         at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
  43.         at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
  44. Caught and handled this exception :
  45. java.lang.NumberFormatException: For input string: ""
  46.         at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  47.         at java.base/java.lang.Integer.parseInt(Integer.java:662)
  48.         at java.base/java.lang.Integer.parseInt(Integer.java:770)
  49.         at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
  50.         at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi.onRegistration(WBMPImageReaderSpi.java:96)
  51.         at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
  52.         at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
  53.         at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
  54.         at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
  55.         at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
  56.         at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
  57.         at com.imooc.o2o.util.ImageUtil.main(ImageUtil.java:90)
  58. Caught and handled this exception :
  59. java.lang.NumberFormatException: For input string: ""
  60.         at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  61.         at java.base/java.lang.Integer.parseInt(Integer.java:662)
  62.         at java.base/java.lang.Integer.parseInt(Integer.java:770)
  63.         at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
  64.         at com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi.onRegistration(BMPImageReaderSpi.java:97)
  65.         at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
  66.         at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
  67.         at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
  68.         at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
  69.         at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
  70.         at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
  71.         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-3-28 22:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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