Skip to content

Commit 1d4a0e9

Browse files
committed
Correção bug ao salvar imagem png com fundo transparente
1 parent c3fa989 commit 1d4a0e9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/ImageGd/ImageGd.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,25 @@ public function imageCreateFrom(string $mimeType, string $filename)
130130
* Image adjustments
131131
*
132132
* @param resource $image
133+
* @param string $mimeType
133134
* @return boolean
134135
*/
135-
public function imageAdjustments($image = null) : bool
136+
public function imageAdjustments($image = null, string $mimeType = '') : bool
136137
{
137138
if ($image == null) {
138139
$image = $this->imageResource;
139140
}
141+
142+
$blendmode = true;
143+
if($mimeType == 'image/png') {
144+
$blendmode = false;
145+
}
140146

141147
if(!imagepalettetotruecolor($image)) {
142148
return false;
143149
};
144150

145-
if(!imagealphablending($image, true)) {
151+
if(!imagealphablending($image, $blendmode)) {
146152
return false;
147153
}
148154

src/ImageGd/ResizeImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function execute() : bool
137137
$imageDst = imagecreatetruecolor($width, $height);
138138

139139
//image adjustments
140-
if (!$this->getImageGd()->imageAdjustments($imageDst)) {
140+
if (!$this->getImageGd()->imageAdjustments($imageDst, $this->getFile()['mimeType'])) {
141141
return false;
142142
}
143143

src/ImageGd/WatermarksImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function execute() : bool
141141
}
142142

143143
//image adjustments
144-
if (!$this->getImageGd()->imageAdjustments($image)) {
144+
if (!$this->getImageGd()->imageAdjustments($image, $this->getFile()['mimeType'])) {
145145
return false;
146146
}
147147

0 commit comments

Comments
 (0)