Skip to content
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

Enforce specific PNG compression level of 9 #1684

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

Caprico85
Copy link
Contributor

Description (*)

Currently, Magento calculates the compression level for PNG images based on the desired image quality. For higher image qualities the compresseion is lowered or even disabled completely. This doesn't makes sense because PNG compression is lossless. Higher compression levels don't degrade image quality. Even worse, for the default quality of 90 a compression level of 1 is calculated. This is the lowest possible compression. If you increase the quality to 95, a compression level of 0 is calculated which disables PNG compression completely.

My pull request changes that so PNG compression is not calculated from image quality anymore. Instead, PNG compression is now defined in system configuration. As default value I set 9 (highest possible compression) because images are usually only resized compressed once and then cached on disk.

Manual testing scenarios (*)

Assign a PNG image as a product image. Change the image quality in Mage_Catalog_Model_Product_Image and look how the file size of the resized image changes.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added Component: Catalog Relates to Mage_Catalog Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* labels Jun 11, 2021
fballiano
fballiano previously approved these changes Jun 15, 2021
@luigifab
Copy link
Contributor

luigifab commented Jun 17, 2021

And... without configuration? For PNG we set $quality to 9, because higher compression levels don't degrade image quality, and it reduce network usage.

@Caprico85
Copy link
Contributor Author

I updated my PR. The compression is now always set to 9.

@Flyingmana Flyingmana changed the title Make PNG compression level configurable Enforce specific PNG compression level of 9 Jul 13, 2021
@Flyingmana Flyingmana merged commit b2001b3 into OpenMage:1.9.4.x Jul 13, 2021
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
6 runs  ±0  4 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit b2001b3. ± Comparison against base commit 94563c7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants