佐佐sama 发表于 2019-8-31 13:26:52

关于Thumbnails问题

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)

minidog 发表于 2019-9-25 12:48:57

你的basePath是什么,检查下是否有错。
本地已执行你的代码,正确无误

minidog 发表于 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");

    }

大蚂虾 发表于 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)

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

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


我能想到的排查思路就这些了{:10_269:}
页: [1]
查看完整版本: 关于Thumbnails问题