-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add append_images support for ICO #4568
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
Changes from 3 commits
07b24c6
52b9b43
39f4738
4ca8a35
a357ff1
2ae597c
1ced7b7
0722870
46f7b4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ def _save(im, fp, filename): | |
| sizes = list(sizes) | ||
| fp.write(struct.pack("<H", len(sizes))) # idCount(2) | ||
| offset = fp.tell() + len(sizes) * 16 | ||
| alt_images = {im.size: im for im in im.encoderinfo.get("append_images", [])} | ||
| for size in sizes: | ||
|
||
| width, height = size | ||
| # 0 means 256 | ||
|
|
@@ -63,9 +64,12 @@ def _save(im, fp, filename): | |
| fp.write(struct.pack("<H", 32)) # wBitCount(2) | ||
|
|
||
| image_io = BytesIO() | ||
| # TODO: invent a more convenient method for proportional scalings | ||
| tmp = im.copy() | ||
| tmp.thumbnail(size, Image.LANCZOS, reducing_gap=None) | ||
| if size in alt_images: | ||
| tmp = alt_images[size] | ||
| else: | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # TODO: invent a more convenient method for proportional scalings | ||
| tmp = im.copy() | ||
| tmp.thumbnail(size, Image.LANCZOS, reducing_gap=None) | ||
| tmp.save(image_io, "png") | ||
| image_io.seek(0) | ||
| image_bytes = image_io.read() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.