Here is a macro that allows the user to change the JPEG quality
setting before saving. Add it to ImageJ/macros/StartupMacros.txt and
you will be able to save in JPEG format by pressing "j". You will
need to write a plugin that extends JFileChooser to show the setting
in the save dialog.
macro "Save As JPEG... [j]" {
quality = call("ij.plugin.JpegWriter.getQuality");
quality = getNumber("JPEG quality (0-100):", quality);
run("Input/Output...", "jpeg="+quality);
saveAs("Jpeg");
}
-wayne
On Feb 19, 2007, at 6:08 PM, Jon Harman wrote:
> Hi,
>
> I'd like to make a jpeg save dialog that shows the quality setting
> and allows the user to change it before saving (I would recommend
> this usage as the default for ImageJ). I can see how to set it,
> but don't know how to get it. It would also be nice if the quality
> number could be incorporated into the file save dialog, to reduce
> the number of clicks needed. Here is a fragment of my code:
>
> double jpegqual = 75;
>
> GenericDialog gd1 = new GenericDialog("JPEG Quality, 100 is
> best");
> gd1.addNumericField("Quality (0-100)",jpegqual,0);
>
> gd1.showDialog();
> if(!gd1.wasCanceled()) {
> jpegqual = gd1.getNextNumber();
> IJ.run("Input/Output...", "jpeg=" + IJ.d2s(jpegqual));
> IJ.run("Jpeg...");
> }
>
> Jon