Skip to content

Losslessly recompress PNGs to save space#3087

Merged
alex-w merged 1 commit into
Stellarium:masterfrom
afontenot:recompress-textures
Mar 15, 2023
Merged

Losslessly recompress PNGs to save space#3087
alex-w merged 1 commit into
Stellarium:masterfrom
afontenot:recompress-textures

Conversation

@afontenot
Copy link
Copy Markdown
Contributor

@afontenot afontenot commented Mar 7, 2023

Description

Many of the PNGs included for textures or other reasons in Stellarium were poorly optimized.
I ran all of them through a PNG compressor to reduce their size. The resulting images are not
changed in any way - the operation is fully lossless - but the installed size of Stellarium is reduced
by more than 32 MB.

This makes it easier to download and use Stellarium on metered connections that are common
worldwide.

I used ect with options

ect --strict -9

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update

How Has This Been Tested?

As no changes to code are involved here, testing and code review don't appear to be relevant.
If there's something I've missed I'm happy to look at this further.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Thanks for adding your first pull request to Stellarium. If you have questions, please do not hesitate to contact us.

@gzotti
Copy link
Copy Markdown
Member

gzotti commented Mar 8, 2023

Good idea, thank you. However, as the buttons are created from SVGs, this should be added to the processing chain, and recompressing PNG screenshots for the Guide should be recommended in the Guide's README (The optimal way would be a fast check to attempt recompression of updated or new PNGs). I don't know ect, does this build&run on all our platforms?

@alex-w alex-w added this to the 23.1 milestone Mar 8, 2023
@alex-w
Copy link
Copy Markdown
Member

alex-w commented Mar 8, 2023

Good idea, thanks!

I agreed with Georg, some documentation/instructions are required.

@afontenot
Copy link
Copy Markdown
Contributor Author

One option for now is I could do a version of this PR skipping the changes to automatically generated button PNGs. There's still a ton of space to be saved on long term assets like space imagery.

ECT compiles for Win / Mac / Linux and compiles on ARM as well I believe. You could also potentially download static builds for Win / Mac if that's appropriate for your build pipeline. One issue is that you wouldn't want to run this tool on the whole build every time, because it's quite slow (especially in the maximum compression mode that I used - I left it to run overnight). So you'd want to set it just to run on the button images, maybe with ect -3 (the default) instead of -9.

If you wanted to require PRs that make changes to images to always pre-optimize them you could use a simple test like

ect -9 --strict $imagefile | grep -q '^Saved 0B out of'

as the grep would fail whenever ect manages to reduce the size of an image.

@10110111
Copy link
Copy Markdown
Contributor

10110111 commented Mar 9, 2023

as the buttons are created from SVGs, this should be added to the processing chain

This is not done automatically. One just opens the SVG in Inkscape, selects a square as described there and exports. There's no automatic processing chain.

@github-actions github-actions Bot added the has conflicts The pull request has conflicts label Mar 10, 2023
@github-actions
Copy link
Copy Markdown

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@gzotti
Copy link
Copy Markdown
Member

gzotti commented Mar 10, 2023

All this doc about ect should go into e.g. a new section in MAINTAINER_BUSINESS. Occasionally, recently added textures can then be recompressed. (E.g. during preparation of each release?)

@alex-w
Copy link
Copy Markdown
Member

alex-w commented Mar 11, 2023

E.g. during preparation of each release?

For newly added images - of course!

@alex-w
Copy link
Copy Markdown
Member

alex-w commented Mar 13, 2023

@afontenot please resolve conflict

@github-actions github-actions Bot removed the has conflicts The pull request has conflicts label Mar 14, 2023
@github-actions
Copy link
Copy Markdown

Conflicts have been resolved. A maintainer will review the pull request shortly.

@afontenot
Copy link
Copy Markdown
Contributor Author

I've rebased the PR and also added some explanatory text to MAINTAINER_BUSINESS. This could be revised or expanded as necessary, perhaps in future commits.

Copy link
Copy Markdown
Member

@alex-w alex-w left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Member

@gzotti gzotti left a comment

Choose a reason for hiding this comment

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

Good description, thank you!

@alex-w alex-w merged commit db016fc into Stellarium:master Mar 15, 2023
@alex-w alex-w added the state: published The fix has been published for testing in weekly binary package label Mar 19, 2023
@github-actions
Copy link
Copy Markdown

Hello @afontenot!

Please check the fresh version (development snapshot) of Stellarium:
https://github.com/Stellarium/stellarium-data/releases/tag/weekly-snapshot

@alex-w alex-w removed the state: published The fix has been published for testing in weekly binary package label Mar 27, 2023
@github-actions
Copy link
Copy Markdown

Hello @afontenot!

Please check the latest stable version of Stellarium:
https://github.com/Stellarium/stellarium/releases/latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants