If height is scaled down significantly more than width, resize vertically first - #9549
If height is scaled down significantly more than width, resize vertically first#9549radarhere wants to merge 6 commits into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
I merged main in, and Benchmark passed, but I don't know how if/how much the improvement is. |
|
According to CodSpeed, ~4% faster, so could be measurement noise and as such unreported. |
|
Ok. The benchmark tests don't cover reducing height but not width, so it at least confirms that this doesn't make things worse for other scenarios. |
hugovk
left a comment
There was a problem hiding this comment.
There's a performance regression for reducing very tall images also with a width reduction:
❯ python -c "
import timeit
from PIL import Image
im = Image.new('RGB', (50, 500000))
print(min(timeit.repeat(lambda: im.resize((40, 1000)), number=5, repeat=3)) / 5 *
1000, 'ms')
"
155.0545250007417 ms❯ python -c "
import timeit
from PIL import Image
im = Image.new('RGB', (50, 500000))
print(min(timeit.repeat(lambda: im.resize((40, 1000)), number=5, repeat=3)) / 5 *
1000, 'ms')
"
212.88325839996105 ms| bounds_vert[i * 2] -= ybox_first; | ||
| #define PASS(function, w, h, offset, ksize, bounds, kk) \ | ||
| second_pass = imTemp != NULL; \ | ||
| imTemp = ImagingNewDirty(imIn->mode, w, h); \ |
There was a problem hiding this comment.
Possible memory leak here: if the second pass's ImagingNewDirty fails, imTemp is overwritten with NULL before we goto end, so the intermediate image from the first pass (now only referenced by imIn) is never deleted. We had an ImagingDelete(imTemp) call before.
There was a problem hiding this comment.
Good catch. I've pushed a commit.
Merging this PR will not alter performance
Comparing Footnotes
|
8fe0002 to
68c7846
Compare
79498e6 to
4194a81
Compare
Ok, that should be fixed now. |
Refining #9524, applying a solution in C, rather than Python