Login  Register

Re: How to know if a file is supported by imageJ without preloading?

Posted by Juanjo Vega on Feb 12, 2010; 10:46am
URL: http://imagej.273.s1.nabble.com/How-to-know-if-a-file-is-supported-by-imageJ-without-preloading-tp3689405p3689414.html

Thank you all,

I'm not using bio-formats, and the way that Wayne proposed doesn't work
for some formats which are opened through plugins. Also Jarek Sacha
proposed another way, something like:

        try {
            final ImageInputStream iis =
ImageIO.createImageInputStream(file);
            final Iterator readers = ImageIO.getImageReaders(iis);

            if (readers.hasNext()) {
                IJ.write(file.getName()+" is supported by imageJ.");
            }
        } catch (Exception ex) {
        }

It works just for images, so I think I could mix both ways, Wayne's and
Jarek's, to get all the supported files.

Sincerelly,

Juanjo.

Glen MacDonald escribió:

> Hi Juanjo,
> I was recently in a similar situation writing a macro to open multiplei image file formats and did not want to have to rely on extensions.  However, as explained by Curtis Rueden, there are only a few formats that declare their identities their headers.  As far as file type support by ImageJ, using the Bio-formats library directly or through the LOCI plugin greatly expands the number of formats that can be opened.  If you have a few specific types of interest, you might be able to parse distinguishing characteristics in the header or metadata, but that might also be cumbersome.  
>
> Good luck,
> Glen
> Glen MacDonald
> Core for Communication Research
> Virginia Merrill Bloedel Hearing Research Center
> Box 357923
> University of Washington
> Seattle, WA 98195-7923  USA
> (206) 616-4156
> [hidden email]
>
>
>
>
>
>
>
>
> On Feb 8, 2010, at 6:37 AM, Juanjo Vega wrote:
>
>  
>> Hello everybody,
>>
>> I'm developing a new plugin and I need a way to know when a file is supported by imageJ.
>>
>> I'm implementing a browser with a preview and the idea is to know when a file is supported or not to show one or another icon. The main idea is to use something like: "isASupportedFileType(): boolean", so new file types will return "true" when a new plugin will be added.
>>
>> Right now I'm filtering items by their extension and that's not cool at all =P
>>
>> Sincerelly,
>>
>> Juanjo.
>>
>> --
>> Juanjo Vega ([hidden email])
>>
>> Unidad de Biocomputación. Laboratorio B-13.
>> Centro Nacional de Biotecnología. CNB-CSIC.
>> C\ Darwin, 3. Campus de Cantoblanco.
>> Universidad Autónoma de Madrid.
>> 28049, Madrid, Spain.
>>
>> http://www.cnb.csic.es
>> http://www.biocomp.cnb.csic.es
>>
>> +34 91 585 4510
>>
>>
>> "Las mejores almas son capaces de los mayores vicios como de las mayores virtudes, y aquellos que caminan despacio por el camino recto pueden llegar más lejos que los que corren pero se apartan de él." - Discurso del Método, René Descartes.
>>    

--
Juanjo Vega ([hidden email])

Unidad de Biocomputación. Laboratorio B-13.
Centro Nacional de Biotecnología. CNB-CSIC.
C\ Darwin, 3. Campus de Cantoblanco.
Universidad Autónoma de Madrid.
28049, Madrid, Spain.

http://www.cnb.csic.es
http://www.biocomp.cnb.csic.es

+34 91 585 4510


"Las mejores almas son capaces de los mayores vicios como de las mayores virtudes, y aquellos que caminan despacio por el camino recto pueden llegar más lejos que los que corren pero se apartan de él." - Discurso del Método, René Descartes.