Skip to content

Commit

Permalink
Merge branch 'feat/submission_attachments_route' of github.com:theus7…
Browse files Browse the repository at this point in the history
…7/elasticms into feat/submission_attachments_route
  • Loading branch information
theus77 committed Oct 25, 2023
2 parents b67dd32 + e61d759 commit b25570c
Show file tree
Hide file tree
Showing 3 changed files with 431 additions and 3 deletions.
17 changes: 14 additions & 3 deletions EMS/common-bundle/src/Storage/Processor/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use EMS\CommonBundle\Common\Standard\Type;
use EMS\CommonBundle\Helper\EmsFields;
use EMS\Helpers\Image\SmartCrop;
use EMS\Helpers\Standard\Color;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -140,11 +141,21 @@ private function fillBackgroundColor(\GdImage $temp): void

private function applyResizeAndBackground(\GdImage $image, int $width, int $height, int $originalWidth, int $originalHeight): \GdImage
{
$temp = $this->imageCreate($width, $height);
$resize = $this->config->getResize();
if ('smartCrop' === $resize) {
$smartCrop = new SmartCrop($image, $width, $height);
$res = $smartCrop->analyse();
if (null === $res['topCrop']) {
$resize = 'fillArea';
} else {
$smartCrop->crop($res['topCrop']['x'], $res['topCrop']['y'], $res['topCrop']['width'], $res['topCrop']['height']);

$this->fillBackgroundColor($temp);
return $smartCrop->get();
}
}

$resize = $this->config->getResize();
$temp = $this->imageCreate($width, $height);
$this->fillBackgroundColor($temp);
$gravity = $this->config->getGravity();

if ('fillArea' == $resize) {
Expand Down
Loading

0 comments on commit b25570c

Please sign in to comment.