Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make PNG compression level configurable
Browse files Browse the repository at this point in the history
Caprico85 committed Jun 8, 2021
1 parent 94563c7 commit 051dc13
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/code/core/Mage/Catalog/etc/config.xml
Original file line number Diff line number Diff line change
@@ -809,6 +809,7 @@
<base_width>1800</base_width>
<small_width>210</small_width>
<max_dimension>5000</max_dimension>
<png_compression>9</png_compression>
</product_image>
<seo>
<product_url_suffix>.html</product_url_suffix>
8 changes: 8 additions & 0 deletions app/code/core/Mage/Catalog/etc/system.xml
Original file line number Diff line number Diff line change
@@ -228,6 +228,14 @@
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
</progressive_threshold>
<png_compression translate="label comment">
<label>PNG Compression Level</label>
<comment>Range: 0 (no compression) to 9 (highest compression)</comment>
<frontend_type>text</frontend_type>
<validate>validate-number</validate>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
</png_compression>
</fields>
</product_image>
<placeholder translate="label">
9 changes: 1 addition & 8 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
@@ -205,14 +205,7 @@ public function save($destination=null, $newName=null)
// set quality param for PNG file type
if (!is_null($this->quality()) && $this->_fileType == IMAGETYPE_PNG)
{
$quality = round(($this->quality() / 100) * 10);
if ($quality < 1) {
$quality = 1;
} elseif ($quality > 10) {
$quality = 10;
}
$quality = 10 - $quality;
$functionParameters[] = $quality;
$functionParameters[] = (int) Mage::getStoreConfig('catalog/product_image/png_compression');
}

call_user_func_array($this->_getCallback('output'), $functionParameters);

0 comments on commit 051dc13

Please sign in to comment.