Title: Use indexed color for PNG images in PDF files when possible by mpetroff · Pull Request #17895 · matplotlib/matplotlib · GitHub
Open Graph Title: Use indexed color for PNG images in PDF files when possible by mpetroff · Pull Request #17895 · matplotlib/matplotlib
X Title: Use indexed color for PNG images in PDF files when possible by mpetroff · Pull Request #17895 · matplotlib/matplotlib
Description: PR Summary This pull requests modifies the PDF backend to use indexed color for PNG images in PDF files when possible. When PNG images have 256 colors or fewer, it converts them to indexed color before saving them in a PDF. This can result in a significant reduction in file size in some cases. The is particularly true for raster data that uses a colormap but no interpolation, such as Healpy mollview plots (for some of the maps I tested, the new PDFs are less than half the size). Currently, this is only done for RGB images. For grayscale images with 128 colors or fewer, there should also be an improvement, since this allows for 4-bit indexed color (or lower) instead of 8-bit grayscale. However, Pillow seems to always use 8-bit indexed color, so there's no improvement in practice. Edit: The PDF specification requires that soft-mask images must use the DeviceGray color space, so they can't be indexed color; this would further complicate extending indexed color to grayscale images, since the PDF backend uses soft-masks. PR Checklist [Existing PDF tests should cover this] Has Pytest style unit tests Code is Flake 8 compliant [Not applicable] New features are documented, with examples if plot related [Not applicable] Documentation is sphinx and numpydoc compliant [Not applicable] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) [Not applicable] Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way
Open Graph Description: PR Summary This pull requests modifies the PDF backend to use indexed color for PNG images in PDF files when possible. When PNG images have 256 colors or fewer, it converts them to indexed color be...
X Description: PR Summary This pull requests modifies the PDF backend to use indexed color for PNG images in PDF files when possible. When PNG images have 256 colors or fewer, it converts them to indexed color be...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/17895
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cd071108-71fc-cb19-00fe-1d053828d354 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AEF2:17A244:18E831C:21D3A6B:6A53623B |
| html-safe-nonce | 21bd1c25e83c56fed0af3204fa49fc9f9ba727297cfdee39c13a7660da4c23d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUYyOjE3QTI0NDoxOEU4MzFDOjIxRDNBNkI6NkE1MzYyM0IiLCJ2aXNpdG9yX2lkIjoiNzk3ODA5MzIyODA0MDg3MjUwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9a4770a35f97337e5ab3d12d892992348d9d7bb654b36fec7d9ef2191ca19ce3 |
| hovercard-subject-tag | pull_request:447851664 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/17895/files |
| twitter:image | https://avatars.githubusercontent.com/u/1450212?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1450212?s=400&v=4 |
| og:image:alt | PR Summary This pull requests modifies the PDF backend to use indexed color for PNG images in PDF files when possible. When PNG images have 256 colors or fewer, it converts them to indexed color be... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width