-
Notifications
You must be signed in to change notification settings - Fork 3
Try gdImageCrop + gdImageScale instead of legacy gdImageCopyResampled #2
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
Conversation
Try gdImageCrop + gdImageScale instead of legacy gdImageCopyResampled
Oh great, thanks, I'll test this. I assumed avoiding the separate crop would be faster. Yes, the sharpen takes 1s of the 3s run time, ouch. No, I've not tried to make vips-bench work on OS X, it's too hard to measure memuse portably. You'd need to find some other way to do that. |
On everything higher-quality than bilinear, we can compose the sharpen and resize kernels, and avoid any overhead whatsoever. The crop and resize operations are also composable. But not in gd 2.1.0. If you build libgd with tiff support, you might be able to make a closer comparison. At minimum there should be a 30% improvement. Our build script may make that easier, as it builds all the dependencies from source:
|
Yes, that does give a speedup. I now see:
Are your improvements in gd master? I'll try making my own gd. |
No, our improvements aren't in the gd repository yet. In fact, they're currently designed to work with GDI+, since that was our use case. They're currently AGPL licensed here: https://github.com/imazen/resizer/tree/develop/Plugins/FastScaling Backporting them to gd will require
|
what is the purpose of these improvements - to create a fair benchmark with GD ? |
Both LibGD and libvips differ considerably from reference software such as ImageWorsener. Ideally they would match with only off-by-one errors. |
What size are the images in your test ? |
git master libvips has some improvements to downsample accuracy, it might be worth testing that. |
gdImageCopyResampled is retained for compatibility purposes, but in theory should be quite a bit slower than gdImageScale (which defaults to bilinear).
Also, gdImageSharpen is extremely inefficient, and should be avoided in favor of a composed scaling and sharpening weight kernel (which, unfortunately, isn't in the mainstream release yet).
vips-bench doesn't seem to work on OS X (
/usr/bin/time: illegal option -- f usage: time [-lp] command.
, and there are many warnings when linking against vips 7.42.1). I can't run the benchmark myself, but I think these changes may help.