Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/robsonvleite/cropper
Browse files Browse the repository at this point in the history
� Conflicts:
�	README.md
  • Loading branch information
robsonvleite committed Jun 13, 2020
2 parents 053af93 + 153ba57 commit 91e1169
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Cropper.php
Expand Up @@ -49,7 +49,7 @@ public function __construct(string $cachePath, int $jpgQuality = 75, int $pngCom
$this->cacheSize = [$jpgQuality, $pngCompressor];

if (!file_exists($this->cachePath) || !is_dir($this->cachePath)) {
if (!mkdir($this->cachePath, 0755)) {
if (!mkdir($this->cachePath, 0755, true)) {
throw new \Exception("Could not create cache folder");
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ private function fromJpg(int $width, int $height, int $src_x, int $src_y, int $s
{
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($this->imagePath);
imagecopyresized($thumb, $source, 0, 0, $src_x, $src_y, $width, $height, $src_w, $src_h);
imagecopyresampled($thumb, $source, 0, 0, $src_x, $src_y, $width, $height, $src_w, $src_h);
imagejpeg($thumb, "{$this->cachePath}/{$this->imageName}", $this->cacheSize[0]);

imagedestroy($thumb);
Expand All @@ -221,7 +221,7 @@ private function fromPng(int $width, int $height, int $src_x, int $src_y, int $s

imagealphablending($thumb, false);
imagesavealpha($thumb, true);
imagecopyresized($thumb, $source, 0, 0, $src_x, $src_y, $width, $height, $src_w, $src_h);
imagecopyresampled($thumb, $source, 0, 0, $src_x, $src_y, $width, $height, $src_w, $src_h);
imagepng($thumb, "{$this->cachePath}/{$this->imageName}", $this->cacheSize[1]);

imagedestroy($thumb);
Expand Down

0 comments on commit 91e1169

Please sign in to comment.