-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: ignore aspect ratio (was "Question: Un-uniform scale possible?") #118
Comments
This feature is not currently supported, but is now on the TODO list :) I'm thinking a new "option" method named something like |
that would be exactly what I need as well (See dupe #153) |
I haven't supported this feature in vipsthumbnail because it's hard to do correctly. Upscaling and downscaling are rather different operations and need separate code paths. If you allow hscale and vscale to differ, you at least double the number of code paths you need (both down, both up, hscale down vscale up, vscale down, hscale up), and perhaps double again, since (in some cases) downscale will already have two paths internally. Supporting not-very-different hscale and vscale would be pretty easy, which would probably cover most people. I suppose it could print a warning if the scales are either side of unity or if the scales differ by more than 20%. |
Thanks for the explaination, @jcupitt ! Unfortunately, for my (admittedly rather odd) usecase this would not be helpful. Maybe other users would still approve, dunno. |
Oh, that's a shame. How large a difference do you need? |
The thing is - I don't know! I'm mass-processing images from third party feeds and need to scale them down to a square for further processing. Since i have no control over the source images, the ratio could be anything. If it helps anything: the target square has a size n*n with n being a power of 2, but never greater than 256: smallestEdge = Math.min(orig.width, orig.height, 256);
squareSize = Math.pow(2, Math.floor(Math.log(smallestEdge) / Math.log(2))); |
Wow that is a bizarre use case :) I guess this for some sort of query-by-image-content application? If that's the case I suppose you probably wouldn't care about small errors and a simple solution would be fine. |
You got that right :-) I cannot really say how important "small errors" will be before I tried them out, but since the algorithm is resilient against compression artifacts and such things, it will probably be ok. |
Very happy to accept a PR implementing this feature - there's a fairly basic guide for contributors. |
For reference, I always used timthumb in the past, and found the http://www.binarymoon.co.uk/2011/03/timthumb-proportional-scaling-security-improvements/ This is in some ways related to this ticket |
Thanks to @skedastik this feature will be available in the forthcoming v0.10.0 release. |
Hi folks,
How do I resize an image disrespect of aspect ratio and without cropping and embedded padding to the exact size I want?
In gm's term, it'd be resize(width, height, '!');
Thank you
The text was updated successfully, but these errors were encountered: