Skip to content

Benchmark more codecs - #10001

Open
akx wants to merge 3 commits into
python-pillow:mainfrom
akx:benchmark-more-codecs
Open

akx wants to merge 3 commits into
python-pillow:mainfrom
akx:benchmark-more-codecs

Conversation

@akx

@akx akx commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Refs #9943 (comment) / akx#31.

This extends benchmarks for test_load and test_save for common formats and options.

I hand-picked formats that are likely to be of common modern interest. For instance, ICO/ICNS saving is not covered, because they'd likely spend more time resampling images (which is covered by the resampling tests) than encoding bits.

@akx
akx force-pushed the benchmark-more-codecs branch from fb35993 to 13e2437 Compare September 15, 2026 10:14
@akx
akx marked this pull request as ready for review September 15, 2026 10:53
Comment thread Tests/test_file_webp.py Outdated
def test_read_lossless(self) -> None:
# generated with: cwebp -z 9 hopper.ppm -o hopper_lossless.webp
with Image.open("Tests/images/hopper_lossless.webp") as webp:
assert_image_equal(webp, hopper("RGB"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought that iss634.webp is already a lossless WebP image that is loaded in our test suite.

What is the intention here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to have a losslessly compressed Hopper WEBP example file. 😄

iss634.webp didn't exactly catch my eye to be lossless (it's only referenced in test_file_webp_animated.py without mention of losslessness). But you're right, webpinfo says the animation frames therein are losslessly compressed... but it's an animation, which would probably take a different decoding path, right?

Also, if I'm correct in assuming that .webp was converted from iss634.gif (5fa2794, 2014), it's bound to only have up to 256 colors as GIFs are wont to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... Curiously, ImageMagick counts unique colors differently across various Hoppers. (I've edited the output below a bit so only the maximum %k of each iss634 frame shows up.)

$ magick identify -format "%f=%k\n" Tests/images/hopper.* Tests/images/iss634* 2>/dev/null | sort
hopper.bmp=9684
hopper.bw=255
hopper.dcx=10100
hopper.dds=9684
hopper.fits=255
hopper.gif=256
hopper.ico=224
hopper.jpg=9675
hopper.pcd=112754
hopper.pfm=255
hopper.png=9684
hopper.pnm=10100
hopper.ppm=10100
hopper.psd=9651
hopper.psd=9651
hopper.psd=9651
hopper.qoi=9684
hopper.ras=9684
hopper.rgb=10100
hopper.sgi=10100
hopper.webp=8361
hopper.xbm=2
hopper.xpm=44
iss634.apng=276
iss634.gif=255
iss634.webp=371

Comment thread Tests/test_file_webp.py Outdated
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants