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 ?
Make your TIFF images into JPGs.Choose File and select Save As. Or, choose File, then Export, and Save for Web (Legacy). Either process can be used to save CMYK, RGB, or grayscale images. Note: JPGs support only 8-bit images, so the bit depth will automatically be lowered on anything with a 16-bit image quality.
Open the image or frame you want to convert. Choose Palette > Set Pixel Depth and select a choice from the submenu (Figure 1). Table 1 shows how pixel depth relates to the number of colors in an image.
An Easy Tip to Convert TIFF to JPG Without Losing Quality Right click on TIFF file, choose “Rename”. Then replace tiff with jpg as the file extension. Press Enter and choose “Use.
IMHO you should use Apache Commons Imaging as it is a advanced and complete imaging solution. I use this to write Tiff
images to PDF. There are plenty of examples. Hope this will helps !!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With