Converting TIFF to JPG in Java is a frequent requirement when developers need to display high‑resolution images on the web or embed them in reports. Conholdate.Total for Java provides a powerful SDK that simplifies this task with just a few lines of code. In this guide you will see a complete, ready‑to‑run example, learn how to handle multi‑page TIFF files, and discover options for controlling quality and resolution. By the end you’ll be able to integrate TIFF to JPG conversion into any Java application with confidence.

The Convert TIFF to JPG in Java Requirements

Java applications that process scanned documents, medical images, or satellite photography often receive input as multi‑page TIFF files. The conversion must preserve detail, support high‑resolution output, and generate a separate JPG for each page to simplify downstream processing. Manual conversion tools cannot be scripted and do not scale, making an automated library essential for batch or real‑time scenarios.

How Conholdate.Total for Java Fits Convert TIFF to JPG in Java

Conholdate.Total for Java offers a dedicated conversion engine that understands the TIFF format, including multi‑page images, and can produce high‑quality JPG output. The SDK lets you set output quality, DPI resolution, and page selection, which addresses the need for precise control over image fidelity. Documentation and API references are available to guide you through each feature: see the official documentation and the API reference. With a simple Maven dependency, the library integrates seamlessly into any Java project.

Implementing TIFF to JPG Conversion in Java

The following steps walk you through setting up the project, initializing the SDK, and performing the conversion.

Add Maven Dependency for Conholdate.Total

Include the Conholdate Maven repository and the SDK dependency in your pom.xml. This ensures the library is available at compile time.

<repositories>
  <repository>
    <id>conholdate-repo</id>
    <name>Conholdate Maven Repository</name>
    <url>https://repository.conholdate.com/repo/</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.conholdate</groupId>
  <artifactId>conholdate-total</artifactId>
  <version>24.9</version>
  <type>pom</type>
</dependency>

You can download the latest release from the download page.

Initialise the ConversionHandler

Create an instance of ConversionHandler. The SDK assumes a valid license is set elsewhere in your application.

ConversionHandler conversionHandler = new ConversionHandler();

Refer to the ConversionHandler class for additional initialization options.

Load the TIFF File and Retrieve Page Count

Use LoadOptions and getFileInfo to obtain information about the source TIFF, including the number of pages.

LoadOptions loadOptions = new LoadOptions();
FileInfo fileInfo = conversionHandler.getFileInfo("sample.tif", loadOptions);
TiffFileInfo tiffInfo = (TiffFileInfo) fileInfo;
int pageCount = tiffInfo.getPages().size();

This step is essential for the TIFF to JPG conversion utility in Java, as it enables per‑page processing.

Configure JPG Conversion Options

Set the desired quality, resolution, and the specific page to convert. These settings are part of the High‑Resolution TIFF to JPG conversion in Java workflow.

JpgConvertOptions jpgOptions = new JpgConvertOptions();
jpgOptions.setQuality(90);          // 0‑100
jpgOptions.setResolution(300);      // DPI
jpgOptions.setPageNumber(i + 1);    // 1‑based page index

Execute Conversion Loop and Validate Output

Iterate over each page, perform the conversion, and verify that the resulting JPG file exists.

for (int i = 0; i < pageCount; i++) {
    jpgOptions.setPageNumber(i + 1);
    String outputPath = Paths.get("output", "page_" + (i + 1) + ".jpg").toString();
    conversionHandler.convert("sample.tif", loadOptions, jpgOptions, outputPath);

    File resultFile = new File(outputPath);
    if (resultFile.exists() && resultFile.length() > 0) {
        System.out.println("Successfully converted page " + (i + 1));
    } else {
        System.err.println("Conversion failed for page " + (i + 1));
    }
}

This demonstrates Batch TIFF to JPG Conversion in Java with minimal code.

Complete Code Example: Convert TIFF to JPG with High Resolution Output

The following code shows the full implementation described above.

import com.groupdocs.conversion.ConversionHandler;
import com.groupdocs.conversion.filetypes.FileInfo;
import com.groupdocs.conversion.filetypes.tiff.TiffFileInfo;
import com.groupdocs.conversion.options.load.LoadOptions;
import com.groupdocs.conversion.options.convert.JpgConvertOptions;
import java.io.File;
import java.nio.file.Paths;

public class TiffToJpgConverter {
    public static void main(String[] args) {
        // Input TIFF file (can be multi‑page)
        String inputPath = "sample.tif";

        // Directory where JPG files will be written
        String outputDir = "output";

        // Desired output quality and resolution
        int outputQuality = 90;      // 0‑100
        int outputResolution = 300; // DPI

        // Ensure the output directory exists
        File outFolder = new File(outputDir);
        if (!outFolder.exists()) {
            outFolder.mkdirs();
        }

        try {
            // Initialise the conversion handler (license is assumed to be set elsewhere)
            ConversionHandler conversionHandler = new ConversionHandler();

            // Load options – can be left empty for default behaviour
            LoadOptions loadOptions = new LoadOptions();

            // Retrieve file information to know how many pages the TIFF contains
            FileInfo fileInfo = conversionHandler.getFileInfo(inputPath, loadOptions);
            if (!(fileInfo instanceof TiffFileInfo)) {
                System.err.println("The provided file is not a TIFF image.");
                return;
            }
            TiffFileInfo tiffInfo = (TiffFileInfo) fileInfo;
            int pageCount = tiffInfo.getPages().size();

            // Convert each page of the TIFF to a separate JPG
            for (int i = 0; i < pageCount; i++) {
                JpgConvertOptions jpgOptions = new JpgConvertOptions();
                jpgOptions.setQuality(outputQuality);
                jpgOptions.setResolution(outputResolution);
                jpgOptions.setPageNumber(i + 1); // pages are 1‑based

                String outputPath = Paths.get(outputDir, "page_" + (i + 1) + ".jpg").toString();

                // Perform the conversion
                conversionHandler.convert(inputPath, loadOptions, jpgOptions, outputPath);

                // Simple validation of the result
                File resultFile = new File(outputPath);
                if (resultFile.exists() && resultFile.length() > 0) {
                    System.out.println("Successfully converted page " + (i + 1) + " to " + outputPath);
                } else {
                    System.err.println("Conversion failed for page " + (i + 1));
                }
            }
        } catch (Exception ex) {
            System.err.println("Error during TIFF to JPG conversion: " + ex.getMessage());
            ex.printStackTrace();
        }
    }
}

Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.

Fine-Tuning High‑Resolution Output Settings

Several options let you control the quality and size of the generated JPG files.

  • Quality - Determines JPEG compression level (0‑100). Higher values keep more detail.
    jpgOptions.setQuality(90);
    
  • Resolution - Sets the DPI of the output image. A value of 300 DPI is standard for print‑ready graphics.
    jpgOptions.setResolution(300);
    
  • PageNumber - Specifies which page of a multi‑page TIFF to convert. Changing this value inside a loop enables batch processing.
    jpgOptions.setPageNumber(i + 1);
    

You can also explore additional properties such as setColorMode or setCompressionLevel in the API reference for more advanced scenarios.

Key Takeaways

Converting TIFF to JPG in Java becomes straightforward with Conholdate.Total for Java. The SDK handles multi‑page TIFFs, lets you fine‑tune quality and resolution, and integrates cleanly into Maven‑based projects. Remember to obtain a proper license for production use; pricing details are on the pricing page and a temporary license is available from the temporary license page. With the code and configuration tips provided, you can now add reliable image conversion to any Java application.

Questions You Might Have

How do I convert a multi‑page TIFF to separate JPG files in Java?
Use the ConversionHandler to retrieve the page count, then loop through each page while setting JpgConvertOptions.setPageNumber. The SDK will generate one JPG per page, as shown in the complete example.

What performance considerations should I keep in mind for TIFF to JPG conversion in Java?
Processing large, high‑resolution TIFFs can consume memory. Reusing a single ConversionHandler instance and writing each output file immediately helps keep the memory footprint low. Adjusting the resolution and quality values can also reduce processing time.

Is there a way to perform stream‑based TIFF to JPG conversion without intermediate files?
Yes. The SDK supports stream input and output via overloads of the convert method that accept InputStream and OutputStream. Refer to the API reference for the exact signatures.

Where can I find more examples and support for Conholdate.Total for Java?
The official documentation contains detailed guides, and the community forums are a great place to ask questions and share solutions.

Keep Exploring