net.coobird.thumbnailator.tasks.UnsupportedFormatException: No suitable ImageReader found

使用thumbnailator进行tif文件格式装换时报异常:

2022-11-27 13:57:03.557 ERROR [main] c.k.s.u.TifUtils :39 - No suitable ImageReader found for D:\other\cjsj\YX_324528742375\2022-07-05 15-481657007312538\file\satelliteImage.tif.
net.coobird.thumbnailator.tasks.UnsupportedFormatException: No suitable ImageReader found for D:\other\cjsj\YX_324528742375\2022-07-05 15-481657007312538\file\satelliteImage.tif.
	at net.coobird.thumbnailator.tasks.io.FileImageSource.read(Unknown Source)
	at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source)
	at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
	at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)
	at com.ktkj.system.utils.TifUtils.tifToJpg(TifUtils.java:36)
	at com.ktkj.system.utils.TifUtils.main(TifUtils.java:67)
2022-11-27 13:57:03.557 INFO  [main] c.k.s.u.TifUtils :41 - D:\other\cjsj\YX_324528742375\2022-07-05 15-481657007312538\file\dew.png转换jpg 结束 ---------

业务代码:
 

/**
     * tiff 转 图片
     * @param tiffPath tiff 路径
     * @param jpgPath 图片路径
     */
    public static void tifToJpg(String tiffPath, String jpgPath){

        File file = new File(tiffPath);
        if (!file.exists() || !file.isFile()) {
            logger.info(tiffPath + "未找到文件或文件夹");
            return;
        }
        logger.info(tiffPath + "开始转换 jpg ---------");
        try {
            Thumbnails.of(tiffPath).scale(0.5f).outputQuality(0.8f).toFile(jpgPath);
            logger.info("{} 转换 ————> {} 完成", tiffPath, jpgPath);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
        logger.info(jpgPath + "转换jpg 结束 ---------");
    }

解决方式:

添加如下依赖:

        <dependency>
            <groupId>com.twelvemonkeys.imageio</groupId>
            <artifactId>imageio-tiff</artifactId>
            <version>3.7.0</version>
        </dependency>

具体原因没有细究,因为我是菜鸟,还请大神指点一二。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值