Skip to content
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

Revert #7311: "Read WebP duration after opening" #7406

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

radarhere
Copy link
Member

Reverts #7311, after a comment requesting that we avoid an expensive operation.

For me this is one of the key concepts in Pillow: you can safely open the image file without decoding the whole image (which is much more expensive operation) and get any info from the file.

This reverts commit 39d866b, reversing
changes made to f39f74f.
@homm
Copy link
Member

homm commented Sep 18, 2023

I will try to test does this really affects opening time vs opening & decoding time.

@hugovk hugovk changed the title Revert #7311 Revert #7311: "Read WebP duration after opening" Sep 20, 2023
@homm
Copy link
Member

homm commented Sep 28, 2023

Things even worse than I thought. With the current main the loading time is actually doubled.

Pillow-10.0.1

In [2]: %timeit im = Image.open('/Code/imgs/avif/space.webp')
711 µs ± 5.68 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [3]: %timeit im = Image.open('/Code/imgs/avif/space.webp').load()
14.8 ms ± 243 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [4]: Image.open('/Code/imgs/avif/space.webp').size
Out[4]: (1500, 1000)

python-pillow:main

In [2]: %timeit im = Image.open('/Code/imgs/avif/space.webp')
13.4 ms ± 77 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [3]: %timeit im = Image.open('/Code/imgs/avif/space.webp').load()
26.6 ms ± 73.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

radarhere:webp

In [2]: %timeit im = Image.open('/Code/imgs/avif/space.webp')
714 µs ± 13.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [3]: %timeit im = Image.open('/Code/imgs/avif/space.webp').load()
14.5 ms ± 56 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

@hugovk hugovk merged commit 99e11f9 into python-pillow:main Sep 28, 2023
53 checks passed
@radarhere radarhere deleted the webp branch September 28, 2023 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants