This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Lossless Optimization of PNG files
Type: resource usage Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, methane, serhiy.storchaka, tfs, vstinner
Priority: normal Keywords: patch

Created on 2017-06-13 23:11 by tfs, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2141 closed tfs, 2017-06-13 23:11
PR 8032 merged methane, 2018-06-30 18:24
Messages (7)
msg295969 - (view) Author: Tiago Filipe Silva (tfs) * Date: 2017-06-13 23:11
I took the liberty to apply tools that optimize the binary weight (without loss of quality) of the 14 PNG files present in the Python 3.7 source tree and then applied a pull request (#2141).

Is there anything to be discussed? Thanks.
msg295989 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-14 06:55
What tools did you use, optipng, advpng, pngcrush, pngnq, pngquant, or other? How much space is saved?

Note that some tools remove an information about palette that makes files displaying differently on different platforms and output devises.
msg295990 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-14 07:05
I suggest to work on Sphinx to propose to implement this optimization on the HTML rendering, maybe with optional external tools. What do you think?

Another attempt: bpo-27461 :-)
msg298375 - (view) Author: Tiago Filipe Silva (tfs) * Date: 2017-07-14 21:59
Sorry for the late reply. I had to deal with stuff.

serhiy.storchaka:

> What tools did you use, optipng, advpng, pngcrush, pngnq, pngquant, or other? How much space is saved?

I had half a crate of whiskey that day so I'm going to say optipng and pngcrush were used and if my recollection is good the saved space was ≈ 5 to 50 % depending on the file.

> Note that some tools remove an information about palette that makes files displaying differently on different platforms and output devises.

I am aware of that. But if I understood correctly these files are rendered in documentation, and I don't think they're going to do this in a PlayStation 2. There may be complaints with Windows XP users because I remember for sure that optimized PNG files could not render very well back in those days.

haypo:

> I suggest to work on Sphinx to propose to implement this optimization on the HTML rendering, maybe with optional external tools. What do you think?

Like you I'm very fond of a long-term proper solution and that is, by the way, the solution you deserve.

Unfortunately, I do not have the skills for provide that. I can only give the solution you need (which is smaller files).
msg320795 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-06-30 17:31
It seems PR author removed his repository and the PR can't be merge via conflict.

In master branch:

02:18 $ ll **/*.png
-rw-r--r--  1 inada-n  staff   3732  7  1 02:13 faq/python-video-icon.png
-rwxr-xr-x  1 inada-n  staff  49648  7  1 02:09 howto/logging_flow.png*
-rw-r--r--  1 inada-n  staff  24719  7  1 02:09 library/depgraph-output.png
-rw-r--r--  1 inada-n  staff  11148  7  1 02:09 library/hashlib-blake2-tree.png
-rw-r--r--  1 inada-n  staff  11280  7  1 02:09 library/pathlib-inheritance.png
-rw-r--r--  1 inada-n  staff  45021  7  1 02:09 library/tulip_coro.png
-rw-r--r--  1 inada-n  staff  39585  7  1 02:09 library/turtle-star.png
-rw-r--r--  1 inada-n  staff  48994  7  1 02:13 using/win_installer.png

In lossless_png branch:

$ ll **/*.png
-rw-r--r--  1 inada-n  staff   2791  7  1 02:28 faq/python-video-icon.png
-rwxr-xr-x  1 inada-n  staff  19351  7  1 02:28 howto/logging_flow.png*
-rw-r--r--  1 inada-n  staff  11158  7  1 02:28 library/depgraph-output.png
-rw-r--r--  1 inada-n  staff  10590  7  1 02:28 library/hashlib-blake2-tree.png
-rw-r--r--  1 inada-n  staff   6168  7  1 02:28 library/pathlib-inheritance.png
-rw-r--r--  1 inada-n  staff  33565  7  1 02:28 library/tulip_coro.png
-rw-r--r--  1 inada-n  staff  29964  7  1 02:28 library/turtle-star.png
-rw-r--r--  1 inada-n  staff  37942  7  1 02:28 using/win_installer.png
msg320801 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-06-30 18:22
03:19 $ find . -name '*.png' | xargs optipng -o7
03:20 $ ll **/*.png
-rw-r--r--  1 inada-n  staff   2888  7  1 03:20 faq/python-video-icon.png
-rw-r--r--  1 inada-n  staff  22058  7  1 03:20 howto/logging_flow.png
-rw-r--r--  1 inada-n  staff  11146  7  1 03:20 library/hashlib-blake2-tree.png
-rw-r--r--  1 inada-n  staff   6456  7  1 03:20 library/pathlib-inheritance.png
-rw-r--r--  1 inada-n  staff  36812  7  1 03:20 library/tulip_coro.png
-rw-r--r--  1 inada-n  staff  33808  7  1 03:20 library/turtle-star.png
-rw-r--r--  1 inada-n  staff  42117  7  1 03:20 using/win_installer.png

While this output is bigger than PR-2141, I think it's good enough.
msg320826 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-07-01 07:02
New changeset c6cd164cffedb306a4c6644d9d03072f24da246d by INADA Naoki in branch 'master':
bpo-30660: Doc: Optimize PNG files by optipng (GH-8032)
https://github.com/python/cpython/commit/c6cd164cffedb306a4c6644d9d03072f24da246d
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74845
2018-07-01 07:03:26methanesetstatus: open -> closed
assignee: docs@python
components: + Documentation
versions: + Python 3.8, - Python 3.7
nosy: + docs@python

resolution: fixed
stage: patch review -> resolved
2018-07-01 07:02:55methanesetmessages: + msg320826
2018-06-30 18:24:54methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request7641
2018-06-30 18:22:22methanesetmessages: + msg320801
2018-06-30 17:31:38methanesetnosy: + methane
messages: + msg320795
2017-07-14 21:59:01tfssetmessages: + msg298375
2017-06-14 07:05:20vstinnersetnosy: + vstinner
messages: + msg295990
2017-06-14 06:55:11serhiy.storchakasetmessages: + msg295989
2017-06-14 05:29:14serhiy.storchakasetnosy: + serhiy.storchaka
2017-06-13 23:11:28tfscreate