× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm not sure if this is possible or not, but here goes.  I have a loop 
that converts multi-page TIF files to single page JPEG files...my problem 
comes when the program converts the first page of the TIF successfully 
then throws an exception 
(java.lang.reflect.InvocationTargetException)...is there any possible way 
to completely ignore this exception within my code?  I realize this might 
be taboo, but my method does what i want it to do before it hits this 
exception...here's my code:

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.image.renderable.*;
import com.sun.media.jai.codec.*;
import javax.media.jai.*;

public class Tiff2JPEG {
        public static boolean doTiff2JPEG(String filename, String 
imageDir) {
                String sourceFilename = imageDir + filename;
                try {
                        FileSeekableStream stream = new 
FileSeekableStream(sourceFilename);
                        imageDecoder dec = 
ImageCodec.createImageDecoder("tiff", stream, null);
                        int numofpages = dec.getNumPages();
                        for (i = 0; i <= numofpages; i++) {
                                RenderedImage image = 
dec.decodeAsRenderedImage(i);
                                String targetFilename = imageDir + 
filename.substring(0, filename.lastIndexOf(".")) + i + ".jpg";
                                JAI.create("filestore", image, 
targetFilename, "JPEG");        // this creates the JPG successfully, then 
throws the exception...
                        }
                return true;
                } catch (IOException e) {
                        e.printStackTrace();
                        return false;
                }
        }
 
        public static void main(String args[]) {
                if (doTiff2JPEG("multicolor14pages.tif", "C:\test 
tiffs\")) {
                        System.out.println("JPG Creation Successful!");
                } else {
                        System.out.println("JPG Creation Unsuccessful!");
                }
        }
}

Shane

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.