Beyka / Android-TiffBitmapFactory

MIT License
131 stars 46 forks source link

Converting Tiff to Jpeg #28

Open vkmulloly opened 6 years ago

vkmulloly commented 6 years ago

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

Beyka commented 6 years ago

"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

vkmulloly commented 6 years ago

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

Beyka commented 6 years ago

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