Bart:
I think your script should use the downsample scheme when downsampling, and the generic scheme when upsampling, automatically switching between the two.
This leaves the issue of what is done near the identity in a somewhat undesirable state. But it's reasonable.
Near the identity (say, between 50% and 100%) it could blend the two results in linear light, in such a way that the current generic is all of it at 100% or above, and at 50% it's all the current "downsample".
Hi Nicolas,
I agree. However, during the stage of searching for optimal approaches and filters, I did want to allow the possibility to use either type of algorithm for both up- and down-sampling, for comparisons (without having to change the script itself).
Now that things seem to stabilize (although I'm thinking of a Keys Cubic variable input if that beats Lanczos), the remaining practical difficulty (with a batch script file) is to determine the fact whether one is effectively going to do upsampling or down-sampling, without asking the user for that.
If we were to restrict the input to percentage inputs, then it would be relatively simple, but I did also want to allow some of the ImageMagick
special resizing options, such as fitting to maximum width (or height) to achieve an exact number of pixels (without running the risk of a percentage rounding to 1 pixel more of less than intended). That makes it harder to parse the input and determine if the result will be larger or smaller than the original.
I'm pretty sure it is possible to parse the input and find out what to do, but it could require quite a bit of code (and time to compact and optimize) to do so reliably. As a minimum, it should distinguish between e.g. 800% (obviously upsampling), and 800x800 (could be either upsampling or down-sampling, depending on the input size), or 800x (for maximum width, could also be either up/down), or x800 (for maximum height, could also be either up/down). Ideally it would also allow to parse the other size limiting resizing options (!, >, <, ^, @) that IM recognizes, and determine which direction to take the resampling.
Again, I agree (and I have been looking into it already), but it may take a lot more time to really figure it out than I can currently invest. I suppose I could throw it over the fence of the IM discourse server and let someone else solve it ..., but not before doing an initial attempt myself (may be a character flaw on my side
).
But feel free to call in the troops for their collective knowledge, which is what I do like about fora. The question to ask would be how to parse the IM resize options to determine whether up- or downsampling is going to occur (ideally expressed as a percentage, only to take further decisions on like with 50-100% identity resizes).
Cheers,
Bart