Closed van707 closed 7 years ago
Did I do it right? I'm not that familiar with github
@izekkai I think so, thanks. Hopefully it will be merged soon. I'm using your changes as a composer patch now:
Date: Fri May 19 11:39:17 2017 +0200
ImageResizer: Added the functionality to change background color
diff --git a/Helper/Resizer.php b/Helper/Resizer.php
index d775515..f4637a3 100644
--- a/Helper/Resizer.php
+++ b/Helper/Resizer.php
@@ -61,7 +61,8 @@ class Resizer
'constrainOnly' => true, // Guarantee, that image picture will not be bigger, than it was. It is false by default.
'keepAspectRatio' => true, // Guarantee, that image picture width/height will not be distorted. It is true by default.
'keepTransparency' => true, // Guarantee, that image will not lose transparency if any. It is true by default.
- 'keepFrame' => false // Guarantee, that image will have dimensions, set in $width/$height. Not applicable, if keepAspectRatio(false).
+ 'keepFrame' => false, // Guarantee, that image will have dimensions, set in $width/$height. Not applicable, if keepAspectRatio(false).
+ 'backgroundColor' => array(255,255,255)
];
/**
* @var array
@@ -70,7 +71,8 @@ class Resizer
'constrainOnly' => 'co',
'keepAspectRatio' => 'ar',
'keepTransparency' => 'tr',
- 'keepFrame' => 'fr'
+ 'keepFrame' => 'fr',
+ 'backgroundColor' => 'bc'
];
/**
* @var File
@@ -278,6 +280,7 @@ class Resizer
$imageAdapter->keepAspectRatio($this->resizeSettings['keepAspectRatio']);
$imageAdapter->keepTransparency($this->resizeSettings['keepTransparency']);
$imageAdapter->keepFrame($this->resizeSettings['keepFrame']);
+ $imageAdapter->backgroundColor($this->resizeSettings['backgroundColor']);
$imageAdapter->resize($this->width, $this->height);
$imageAdapter->save($this->getAbsolutePathResized());
return true;
Cool
Hi @izekkai
Thanks for your contribution. I merged the PR and added a small change in your code. I set the default background to null
instead to [255, 255, 255]
. You can find these changes on version 1.1
I needed to change background color so I followed this thread as a guide https://github.com/staempfli/magento2-module-image-resizer/issues/3