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]