Skip to content

Commit

Permalink
Use _write() in data()
Browse files Browse the repository at this point in the history
Signed-off-by: J0WI <[email protected]>
  • Loading branch information
J0WI committed Dec 4, 2022
1 parent aac4b55 commit 461286c
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions lib/private/Image/Gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ protected function _write($filePath = null, $mimeType = null): bool {
$retVal = imagebmp($this->resource, $filePath);
break;
default:
$this->logger->info(__METHOD__ . '(): Could not guess mime-type, defaulting to png', ['app' => 'core']);
$retVal = imagepng($this->resource, $filePath);
}
return $retVal;
Expand Down Expand Up @@ -174,26 +175,7 @@ public function data(): ?string {
return null;
}
ob_start();
switch ($this->mimeType) {
case "image/png":
$res = imagepng($this->resource);
break;
case "image/jpeg":
$quality = $this->getJpegQuality();
if ($quality !== null) {
$res = imagejpeg($this->resource, null, $quality);
} else {
$res = imagejpeg($this->resource);
}
break;
case "image/gif":
$res = imagegif($this->resource);
break;
default:
$res = imagepng($this->resource);
$this->logger->info(__METHOD__ . '(): Could not guess mime-type, defaulting to png', ['app' => 'core']);
break;
}
$res = $this->_write(null, $this->mimeType);
if (!$res) {
$this->logger->error(__METHOD__ . '(): Error getting image data.', ['app' => 'core']);
}
Expand Down

0 comments on commit 461286c

Please sign in to comment.