OK. Leave me flopping around on the deck long enough, and I
will get a result. This works nicely:
rif = currentObject.getRepresentingImageFile();
if(rif != null) {
AlbumImage ai = new AlbumImage(rif, engine);
minDim = Math.min(ai.getBufferedImage().getWidth(), ai.getBufferedImage().getHeight());
JAFilter sq = new CropFilter();
sq.setBounds(new Dimension(minDim, minDim));
ai = ai.applyFilter(sq, new HashMap());
ai = ai.scaleToFit(new Dimension(400,400));
ai.saveImage(new File(outputDirectory, "folderthumb.jpg"));
}
David will probably pop up and show me what I'm doing the hard way, but at least this works.
This is for a square crop - to do something like a 3:2, you'd need to do a little math to get the
setBounds() values. You need to crop the image to the desired aspect ratio before you scale the sucker, or you get very unpleasant results, and to do that, you need to know what its actual dimensions are.
And you might want to tinker with the
setYWeight() and
setXWeight() values on the filter. Lots of landmines with a mix of images.