Opening URLs in ImageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening URLs in ImageJ

Thomas Kuo
I was looking at opening images from a URL, and according to the source
code this is done by reading the extension on the URL.  However, this
does not work in my situation as the URL is generated by a script and
does not have an extension.  The opinion of some of my colleagues is
that extension-based reading is not the way to do this.  Instead it
should be based on the HTTP header information such as the MIME-type or
content-type or input stream (stuff that URLConnection can do).

First of all, do other people think this is a better way of handling
files?  Or there's a better way? Or the current way is fine.

I tried to write a "proof of concept"-type of plugin.  I can show the
entire code if people are interested (it's about 50 lines).  But the
selection part is below:

 >>>> Begin Code <<<<
            URL url = null;
            ImagePlus imp = null;

            if(contentType.equals("application/tiff"))
                imp = opener.openTiff(url.openStream(), name);
            else if (contentType.equals("application/zip"))
                imp = opener.openZip(url);
            else if (contentType.equals("image/dicom")) {
                imp = (ImagePlus)IJ.runPlugIn("ij.plugin.DICOM", fileURL);
                if (imp !=null && imp.getWidth()==0) imp = null;
            } else
                imp = opener.openJpegOrGifUsingURL(name, url);
 >>>> End Code <<<<

I've included this part of the code, because I get the following error
message which baffles me to no end.
 >>>> Begin Error Message <<<<
Note: sun.tools.javac.Main has been deprecated.
C:\Program Files\ImageJ\plugins\URLOpener2_.java:35: No method matching
openZip(java.net.URL) found in class ij.io.Opener.
                imp = opener.openZip(url);
                                    ^
C:\Program Files\ImageJ\plugins\URLOpener2_.java:40: No method matching
openJpegOrGifUsingURL(java.lang.String, java.net.URL) found in class
ij.io.Opener.
                imp = opener.openJpegOrGifUsingURL(name, url);
                                                  ^
2 errors, 1 warning
 >>>> End Error Message <<<<

My ImageJ version information is: ImageJ 1.35l with Java 1.5.0_03
(though I'm not sure if it's using the Java _03 it came with or my
systems Java 1.5.0_06).

~Thomas

--
Thomas Kuo
Graduate Student
Electrical & Computer Engineering Department
University of California Santa Barbara
Email: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Opening URLs in ImageJ

Albert Cardona
Thomas,

The openZip and the openJpegorGif[etc.] are private to the ij.io package,
hence you can't use them (and the misleading "not found" error message).

You have to make them public and recompile the Opener.java file, or suggest
Wayne to do so if it is appropriate in the general context.

Albert


--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.pensament.net/java/
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com