How to convert TIFF to JPEG/PNG in java

前端 未结 5 1446
时光说笑
时光说笑 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:17

    If your target is Android, you could try this great Java library on Github that provides many utilities for handling, opening, and writing .tiff files.

    A simple example from that Git showng how to convert TIFF to JPEG:

    TiffConverter.ConverterOptions options = new TiffConverter.ConverterOptions();
    //Set to true if you want use java exception mechanism
    options.throwExceptions = false; 
    //Available 128Mb for work
    options.availableMemory = 128 * 1024 * 1024; 
    //Number of tiff directory to convert;
    options.readTiffDirectory = 1;         
    //Convert to JPEG
    TiffConverter.convertTiffJpg("in.tif", "out.jpg", options, progressListener);
    

提交回复
热议问题