How to convert TIFF to JPEG/PNG in java

前端 未结 5 1451
时光说笑
时光说笑 2020-12-03 06:08

recently i\'m facing problem when try to display an image file. Unfortunately, the image format is TIFF format which not supported by major web browser (as i know only Safar

5条回答
  •  醉酒成梦
    2020-12-03 06:18

    1. Add dependency

       
       com.github.jai-imageio
       jai-imageio-core
       1.3.1 
      

    https://mvnrepository.com/artifact/com.github.jai-imageio/jai-imageio-core

    https://mvnrepository.com/artifact/com.github.jai-imageio/jai-imageio-core/1.3.1

    1. Coding

      final BufferedImage tif = ImageIO.read(new File("test.tif"));
      ImageIO.write(tif, "png", new File("test.png"));
      

提交回复
热议问题