Re: thumbnail quality
Posted by Wayne Rasband on Dec 08, 2005; 8:41pm
URL: http://imagej.273.s1.nabble.com/thumbnail-quality-tp3704288p3704298.html
> Sounds like macros are the way to go.? I am still new to
> imageJ so I need a little jump start.? I can incorporate
> these macros in my java program.? One more question, I need
> to open the image in order to run the macros, right? Is that
> the open(image) command?? I don't want to actually open the
> file in GUI, rather in memory so I can do the conversion.?
Use the IJ.open() method to open the image. It will not be displayed if
there is no "ImageJ" window. Here is Java code that opens an image and
generates a thumbnail:
IJ.open("MyImage.jpg");
IJ.run("Gaussian Blur...", "radius=2");
IJ.run("Size...", "width=100 height=100 constrain interpolate");
IJ.run("Enhance Contrast", "saturated=0.1");
IJ.saveAs("jpg", "thumbnail.jpg");
As a macro it looks like this:
open(getArgument);
?? run("Gaussian Blur...", "radius=2");
?? run("Size...", "width=100 height=100 constrain interpolate");
?? run("Enhance Contrast", "saturated=0.1");
saveAs("jpg", "thumbnail.jpg");
Save this macro as a file named "thumbnail.txt" and you can run it from
the command line using:
java -jar ij.jar -batch thumbnail MyImage.jpg
You will need to be running ImageJ 1.35j or later, which adds the
-batch command line option.
-wayne