Here's a new image filter for you guys. It's called ConstrainRatioFilter and is similar to FixedShapeFilter in that it crops images but instead of a fixed shape, you set min and max bounds for the aspect ratio (the width / height ratio). The purpose of this is to allow most images to have their thumbnails remain their natural aspect ratio, but make exceptions for panorama images, which tends to look like tiny film strips if they have a really large aspect ratio.
where 0.5F and 2.0F are the min and max ratios. Those values also happen to be the default.
To get squary thumbnails, simply set min and max to 1.
There are also the same xWeight and yWeight variables as FixedShapeFilter has if you wish to adjust the focus when cropping.
To try this filter, put the attached code in a "plugins" folder of your skin. Future jAlbum versions will include it in the shared "plugins" folder.
Edited by: jGromit on 15-Feb-2019 21:09, to fix syntax of sample usage
I hadn't paid much attention to this - I've been up to my whatzit in some other skin improvements (and I'm still wrestling with one of them).
Where this could be a big help is in skins that use a justified gallery of thumbnails. Including a pano in the mix really throws the justified gallery script for a loop. It doesn't malfunction, but it produces an undesirable effect.
A quick comparison.... In the "regular" screenshot, look at what the presence of the pano does to that second row of thumbnails - by necessity, it makes the row very short, vertically. In the "constrained" screenshot, I've restricted the aspect ratio to 2.0.
I think this feature is destined for inclusion in Mercury, Neptune, and Pluto.
Happy to hear it's appreciated! The .class file is enough to include, and as soon as the next jAlbum release is out, it won't be needed to include by skins, but it doesn't hurt to keeping it included either.
...as soon as the next jAlbum release is out, it won't be needed to include by skins....
The catch is that if the skin has some sort of checkbox to invoke the new filter, but doesn't include it in its own files, that version of the skin is then restricted to the newest release.
My skins are all still usable with jAlbum 15.2 (15.4 in one case). I don't hesitate to push users to a newer jAlbum version when it's needed, but with something like this, the skin can cut the users a break.
to the top of my init,bsh file.
But it is not working for me, I get next error message:
Stack trace for jAlbum 18 using skin FancyBox 1.3.4:
se.datadosen.util.ScriptException: Sourced file: inline evaluation of: ``/* * init.bsh last change: 2018-11-09 * Executed only once before the creati . . . '' : Constructor error: Can't find constructor: ConstrainRatioFilter( float, float, int ) in class: ConstrainRatioFilter : at Line: 18 : in file: inline evaluation of: ``/* * init.bsh last change: 2018-11-09 * Executed only once before the creati . . . '' : new ConstrainRatioFilter ( 0.5F , 2F , JAFilter .THUMBNAILS_PRESCALE_STAGE )
in init.bsh at line number 18
Caused by: javax.script.ScriptException: Sourced file: inline evaluation of: ``/* * init.bsh last change: 2018-11-09 * Executed only once before the creati . . . '' : Constructor error: Can't find constructor: ConstrainRatioFilter( float, float, int ) in class: ConstrainRatioFilter : at Line: 18 : in file: inline evaluation of: ``/* * init.bsh last change: 2018-11-09 * Executed only once before the creati . . . '' : new ConstrainRatioFilter ( 0.5F , 2F , JAFilter .THUMBNAILS_PRESCALE_STAGE )
in inline evaluation of: ``/* * init.bsh last change: 2018-11-09 * Executed only once before the creati . . . '' at line number 18
at java.scripting/javax.script.AbstractScriptEngine.eval(Unknown Source)
... 4 more
I hesitate even to suggest this, because it would mean some laborious rewriting of every one of my skins (not difficult - just boring). But given that a lot of the other "filter" stuff is now accessible elsewhere, like on the Effects tab, shouldn't the fixed-shape and constrain-ratio filters be settable on the Images tab, along with the thumbnail bounds? They'd need to be "one or the other or neither," of course, perhaps with a couple of spinners for the constrain-ratio limits.
Yeah, somehow I should unify the 3 APIs we have today for basically doing the same thing - manipulating images.
No need to do that, it costs only development time of you and the skin developers and it offers nothing new for the Users!
It would, for example, allow users to choose fixed-shape thumbnails or constrained aspect ratio thumbnails for any skin, not just the ones where the skin developer has built it in, without sending them into the messy "user variables" world.
After porting the same code into six different skins (and I'm not even touching Matrix and MatrixSlide, or it would be eight skins), it occurred to me that this shouldn't be necessary for something that really is a core image-processing feature, not something skin-specific.
I find it almost comical that you're suggesting that there's no reason to improve the jAlbum core to take over something a skin developer can just as well do on his own. Your history of asking for exactly such changes is a long one.
This is just the short list - I got tired of looking: