mercredi 21 mai 2014

Java - convertir TIF en JPG sans augmentation de la profondeur de Bit - Stack Overflow


I am trying to convert TIF image to JPG image. For that I am using the following code :


    SeekableStream s = new FileSeekableStream(tiffUrl);
TIFFDecodeParam param = null;
ImageDecoder dec = ImageCodec.createImageDecoder(EXT_TIFFX, s, param);
RenderedImage op = dec.decodeAsRenderedImage(0);
FileOutputStream fos = new FileOutputStream(jpgUrl);
JPEGEncodeParam jpgparam = new JPEGEncodeParam();
jpgparam.setQuality(quality);
ImageEncoder en = ImageCodec.createImageEncoder(EXT_JEPGX, fos, jpgparam);
en.encode(op);
fos.flush();
fos.close();
s.close();

Before conversion my image size was approx 92KB and Bit Depth = 1 After conversion my new jpg image size is approx 1573KB and Bit Depth = 24


I need to manage my new image under 100KB. And I suppose this can be done if I control the Bit Depth to 1 itself.


Is there any solution helpful to perform this ?



I am trying to convert TIF image to JPG image. For that I am using the following code :


    SeekableStream s = new FileSeekableStream(tiffUrl);
TIFFDecodeParam param = null;
ImageDecoder dec = ImageCodec.createImageDecoder(EXT_TIFFX, s, param);
RenderedImage op = dec.decodeAsRenderedImage(0);
FileOutputStream fos = new FileOutputStream(jpgUrl);
JPEGEncodeParam jpgparam = new JPEGEncodeParam();
jpgparam.setQuality(quality);
ImageEncoder en = ImageCodec.createImageEncoder(EXT_JEPGX, fos, jpgparam);
en.encode(op);
fos.flush();
fos.close();
s.close();

Before conversion my image size was approx 92KB and Bit Depth = 1 After conversion my new jpg image size is approx 1573KB and Bit Depth = 24


I need to manage my new image under 100KB. And I suppose this can be done if I control the Bit Depth to 1 itself.


Is there any solution helpful to perform this ?


0 commentaires:

Enregistrer un commentaire