Convert TIFF to JPEG using Java Advance Imaging

Java advance imaging API allows you to convert Tiff to JPEG. You need to download & install Java Advance Imaging before adding conversion functionality in your project.

Below is the method and usage for converting Tiff to JPEG in JAVA.

Method: Create a class Imagecl and add below method to it.

public static void ConvertTiffToJpg(String str_TiffUrl, String str_JpgFileDestinationUrl) throws Exception
      FileSeekableStream obj_FileSeekableStream = new FileSeekableStream(new File(str_TiffUrl));
      ImageDecoder obj_ImageDecoder = ImageCodec.createImageDecoder("tiff", obj_FileSeekableStream, null);
      RenderedImage obj_RenderedImage = obj_ImageDecoder.decodeAsRenderedImage();
      JAI.create("filestore",obj_RenderedImage,str_JpgFileDestinationUrl, "jpeg");
      obj_RenderedImage = null;
      obj_ImageDecoder = null;
    catch(Exception ex)
      throw ex;



String str_TiffFileUrl = request.getRealPath("TIFF_Folder_Path_In_Project/TIFF_File_Name");
String str_JPGFileUrl= request.getRealPath("JPG_Folder_Path_In_Project/JPG_File_Name");
Imagecl.TiffToJpg(str_TiffFileUrl, str_JPGFileUrl);

Tags: , , , , ,

Comments & Responses

Leave a Reply

Your email address will not be published. Required fields are marked *


6 × = 18

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>