Android-TiffBitmapFactory icon indicating copy to clipboard operation
Android-TiffBitmapFactory copied to clipboard

Converting Tiff to Jpeg

Open vkmulloly opened this issue 7 years ago • 3 comments

TiffConverter.convertTiffJpg("/sdcard/in.tif", "/sdcard/out.jpg", options, progressListener);

Hi i am trying to convert tiff to jpeg format but my output is showing last captured image only,how i get both files converted, and also please help me to convert tiff to base64 format

vkmulloly avatar Feb 12 '18 07:02 vkmulloly

"Hi i am trying to convert tiff to jpeg format but my output is showing last captured image " What you mean? If you trying convert few images, you should do it in cycle and use new output name, because jpeg not support multi page.

As for base 64 - you should open till work TiffBitmapFacrory and then convert obtained Bitmap object to base 64

Beyka avatar Feb 12 '18 07:02 Beyka

I have one Tiff file which contain 2 jpeg image, i want to extract to 2 individual jpeg files from that tiff file please help with sample code

vkmulloly avatar Feb 13 '18 12:02 vkmulloly

if your tiff contains few directories, you could use code like this:

TiffConverter.ConverterOptions options = new TiffConverter.ConverterOptions();
options.throwExceptions = false; //Set to true if you want use java exception mechanism;
options.availableMemory = 128 * 1024 * 1024; //Available 128Mb for work;

for (int i = 0; i < 2; i++) {
    options.readTiffDirectory = i; //Number of tiff directory to convert;
        
    //Convert to JPEG
    TiffConverter.convertTiffJpg("/sdcard/in.tif", "/sdcard/out" + i + ".jpg", options, progressListener);
}

You just use options.readTiffDirectory to specify which directory you want to convert

Beyka avatar Feb 13 '18 17:02 Beyka