| From | Sent On | Attachments |
|---|---|---|
| Fabrizio Giudici | Jun 14, 2007 4:48 am | |
| mja...@union06.de | Jun 14, 2007 5:08 am | |
| Fabrizio Giudici | Jun 14, 2007 5:20 am | |
| robert engels | Jun 14, 2007 6:41 am | |
| Fabrizio Giudici | Jun 14, 2007 1:55 pm | |
| robert engels | Jun 14, 2007 2:25 pm | |
| Fabrizio Giudici | Jun 14, 2007 4:07 pm | |
| jai-...@javadesktop.org | Jun 14, 2007 6:14 pm | |
| robert engels | Jun 14, 2007 6:26 pm | |
| Brian Burkhalter | Jun 14, 2007 6:28 pm | |
| robert engels | Jun 14, 2007 6:30 pm | |
| Brian Burkhalter | Jun 14, 2007 6:31 pm | |
| mja...@union06.de | Jun 15, 2007 12:09 am |
| Subject: | Re: [JAI-IMAGEIO] Strange problem with TIFF reading on Mac OS X | |
|---|---|---|
| From: | robert engels (reng...@ix.netcom.com) | |
| Date: | Jun 14, 2007 6:41:37 am | |
| List: | net.java.dev.jai-imageio.interest | |
The Mac JVM contains a TIFF ImageIO plugin as well. I have found it to be not as good as the one included in ImageIO tools, and can't read certain TIFFs.
I look for it and ignore it using code similar to the following:
/** * get an ImageReader for an ImageInpuStream. We have a preference for providers since consistent image processing is * a requirement. * * @param iis the non-null stream * @return the ImageReader * @throws ImageIOException if a suitable ImageReader cannot be found */ private static ImageReader getImageReader(ImageInputStream iis) throws ImageIOException { Iterator iter = ImageIO.getImageReaders(iis);
ImageReader reader = null; while(iter.hasNext()) { reader = (ImageReader) iter.next(); String classname = reader.getClass().getName();
// always use the imageio tools TIFF reader if(classname.indexOf("TIFF")>=0 && !classname.equals ("com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader")) { if(logger.isDebugOn()) logger.debug("skpping reader "+classname); continue; } break; } if (reader==null) { throw new ImageIOException("no reader available"); } return reader; }
On Jun 14, 2007, at 6:48 AM, Fabrizio Giudici wrote:
Hello.
I use the following code to find out the ImageReader to deal with a certain file:
private static ImageReader createImageReader (final ImageInputStream imageInputStream, final String suffix) throws IOException { try { for (Iterator<ImageReader> iterator = ImageIO.getImageReadersBySuffix(suffix); iterator.hasNext();) { ImageReader reader = iterator.next(); String pluginClassName = reader.getOriginatingProvider().getPluginClassName();
logger.finer(">>>> testing reader: " + reader + ", pluginClassName: " + pluginClassName);
if ((reader != null) && !unwantedPlugins.contains (pluginClassName) && reader.getOriginatingProvider ().canDecodeInput(imageInputStream)) { reader.setInput(imageInputStream); logger.finer(">>>> returning reader: " + reader + ", pluginClassName: " + pluginClassName); return reader; } }
throw new IOException("No ImageReader for the suffix: " + suffix); }
Of course JAI-IMAGEIO is in the classpath. In facts in the log I see:
13:24:02.810 [AWT-EventQueue-1 ] FINE ReadOp - getImageReader(/Users/fritz/Business/ Tidalwave/Projects/blueMarine/Test/Pleiades Small Set/w1.tif) 13:24:02.810 [AWT-EventQueue-1 ] FINER ReadOp - >>>> suffix is tif 13:24:02.812 [AWT-EventQueue-1 ] FINER ReadOp - >>>> testing reader: com.sun.imageio.plugins.tiff.TIFFImageReader@5b8c7f, pluginClassName: com.sun.imageio.plugins.tiff.TIFFImageReader
Nevertheless, the "canDecodeInput()" returns false and the method fail. This happens only on Mac OS X; the same application works fine with Linux and Windows. What's the problem?
PS Maybe I've read in the past months about a possible problem with TIFFs and Mac OS X but I can't recall.
-- Fabrizio Giudici, Ph.D. - Java Architect, Project Manager Tidalwave s.a.s. - "We make Java work. Everywhere." weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog Fabr...@tidalwave.it - mobile: +39 348.150.6941





