|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
|
|
|
RE: Merging TIFFs with different resolutionsWhat version of Java are you using to compile?
> -----Original Message----- > From: jai-interest@... > [mailto:jai-interest@...] > Sent: Wednesday, March 19, 2008 6:51 PM > To: interest@... > Subject: Re: [JAI] Merging TIFFs with different resolutions > > I need to combine >1 tiff to create a multi-page tiff. > > From previous post, I can't get this line to compile: > > import java.io.IOException; > import java.io.*; > import java.util.*; > import java.lang.Object; > import java.lang.String; > import java.lang.Integer; > > public class mergeTifs { > public static void main (final String args[]) throws Exception { > doTifs(args); > } > > public static void doTifs(String args[]) { > try { > List<IIOImage> imageList = new ArrayList<IIOImage>(); > .... > > I get this error msg: > mergeTifs.java:22: '(' or '[' expected > List<IIOImage> imageList = new ArrayList<IIOImage>(); > > I can't figure this error. Any thoughts ? Thanks ! > [Message sent by forum member 'dave0131' (dave0131)] > > http://forums.java.net/jive/thread.jspa?messageID=264898 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: interest-unsubscribe@... > For additional commands, e-mail: interest-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Merging TIFFs with different resolutionsHie guys! After waiting long time for getting a workable code to merge multi-page tiffs into one tiff, i am posting my solution what i got workable few minutes ago. Thanks in advance to 'lasmith' for the idea how to do it. Main difficulty was to iterate through multi-pages in a tiff file to load it to be merged. How erver, here is my code....
public static void concateTiff(String[] inputTiffs, String outputTiff) { List<IIOImage> imageList = new ArrayList<IIOImage>(); ImageInputStream tiffStream = null; IIOImage tiffImage = null; try { // locate a TIFF reader Iterator<ImageReader> tiffReaders = ImageIO.getImageReadersByFormatName("tiff"); if (!tiffReaders.hasNext()) throw new IllegalStateException("No TIFF reader found"); ImageReader tiffReader = tiffReaders.next(); for (int i = 0; i < inputTiffs.length; i++) { System.out.println("image-" + i); // point it to our image file tiffStream = ImageIO.createImageInputStream(new File(inputTiffs[i])); tiffReader.setInput(tiffStream); // read pages until end of image from the TIFF file try { for (int index = 0;; index++) { tiffImage = tiffReader.readAll(index, tiffReader.getDefaultReadParam()); imageList.add(tiffImage); } } catch (IndexOutOfBoundsException ex) { System.out.println("page limit crossed!"); } } Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff"); ImageWriter writer = writers.next(); ImageOutputStream ios = ImageIO.createImageOutputStream(new File(outputTiff)); writer.setOutput(ios); IIOImage firstIioImage = imageList.remove(0); writer.write(firstIioImage); int i = 1; for (IIOImage iioImage : imageList) { writer.writeInsert(i++, iioImage, null); } ios.close(); tiffStream.close(); } catch (IOException e) { System.out.println("error merging tiff. Msg=" + e.getMessage()); } } Hope it would help. [Message sent by forum member 'ahsan4her' (ahsan4her)] http://forums.java.net/jive/thread.jspa?messageID=265268 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Re: Merging TIFFs with different resolutionsThanks for posting the code. If it did not come through accurately try
reposting to {interest _AT_ jai.dev.java.net} or send it to me and I will post it. Brian On Fri, 21 Mar 2008, jai-interest@... wrote: > Hie guys! After waiting long time for getting a workable code to merge multi-page tiffs into one tiff, i am posting my solution what i got workable few minutes ago. Thanks in advance to 'lasmith' for the idea how to do it. Main difficulty was to iterate through multi-pages in a tiff file to load it to be merged. How erver, here is my code.... > > public static void concateTiff(String[] inputTiffs, String outputTiff) { > List<IIOImage> imageList = new ArrayList<IIOImage>(); > ImageInputStream tiffStream = null; > IIOImage tiffImage = null; > > try { > // locate a TIFF reader > Iterator<ImageReader> tiffReaders = ImageIO.getImageReadersByFormatName("tiff"); > if (!tiffReaders.hasNext()) > throw new IllegalStateException("No TIFF reader found"); > ImageReader tiffReader = tiffReaders.next(); > > for (int i = 0; i < inputTiffs.length; i++) { > System.out.println("image-" + i); > // point it to our image file > tiffStream = ImageIO.createImageInputStream(new File(inputTiffs[i])); > tiffReader.setInput(tiffStream); > // read pages until end of image from the TIFF file > try { > for (int index = 0;; index++) { > tiffImage = tiffReader.readAll(index, tiffReader.getDefaultReadParam()); > imageList.add(tiffImage); > } > } catch (IndexOutOfBoundsException ex) { > System.out.println("page limit crossed!"); > } > } > > Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff"); > ImageWriter writer = writers.next(); > ImageOutputStream ios = ImageIO.createImageOutputStream(new File(outputTiff)); > writer.setOutput(ios); > > IIOImage firstIioImage = imageList.remove(0); > writer.write(firstIioImage); > int i = 1; > for (IIOImage iioImage : imageList) { > writer.writeInsert(i++, iioImage, null); > } > ios.close(); > tiffStream.close(); > } catch (IOException e) { > System.out.println("error merging tiff. Msg=" + e.getMessage()); > } > } > > Hope it would help. > [Message sent by forum member 'ahsan4her' (ahsan4her)] > > http://forums.java.net/jive/thread.jspa?messageID=265268 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: interest-unsubscribe@... > For additional commands, e-mail: interest-help@... > > >^..^< >^..^< Brian Burkhalter Java Imaging and Video Sun Microsystems, Inc. This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Re: Merging TIFFs with different resolutionsDear Brian,
In your reply the i can see the complete code as I posted. But in my posting, code fragment is missing. People can use my code from ur posting. Thanks for immediate attention! [Message sent by forum member 'ahsan4her' (ahsan4her)] http://forums.java.net/jive/thread.jspa?messageID=265959 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Re: Merging TIFFs with different resolutionsHello Brian
I used ur code to mearge two tiff doc. It works fine. but i got an exception 'page limit crossed!', even code working fine. Is there any problem with it. pls explain about this exception. Thanks. [Message sent by forum member 'gyan_801' (gyan_801)] http://forums.java.net/jive/thread.jspa?messageID=275694 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Re: Merging TIFFs with different resolutionsI have no clue as to what error would provoke that message. It would be more helpful to post the actual stack trace.
Brian > Hello Brian > > I used ur code to mearge two tiff doc. It works > fine. > but i got an exception 'page limit crossed!', even > code working fine. > Is there any problem with it. > pls explain about this exception. > > Thanks. http://forums.java.net/jive/thread.jspa?messageID=277102 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: Merging TIFFs with different resolutionsI always get this exception IllegalStateException:No TIFF reader found:
but I change "tiff" to "jpg" still same exception Iterator<ImageReader> tiffReaders = ImageIO.getImageReadersByFormatName("tiff"); if (!tiffReaders.hasNext()) throw new IllegalStateException("No TIFF reader found"); [Message sent by forum member 'tigerwang' (tigerwang)] http://forums.java.net/jive/thread.jspa?messageID=285176 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
| Free Forum Powered by Nabble | Forum Help |