1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-28 08:09:54 +02:00

ResizeModifier

This commit is contained in:
Oliver Vogel
2021-10-30 17:48:34 +02:00
parent d98f906929
commit bab6cef4ae
2 changed files with 31 additions and 1 deletions

View File

@@ -41,7 +41,7 @@ class ResizeModifier implements ModifierInterface
* @param int $src_h
* @return boolean
*/
protected function modify(Frame $frame, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
protected function modify(FrameInterface $frame, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
// create new image
$modified = imagecreatetruecolor($dst_w, $dst_h);
@@ -76,6 +76,8 @@ class ResizeModifier implements ModifierInterface
$src_h
);
imagedestroy($gd);
// set new content as recource
$frame->setCore($modified);
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Intervention\Image\Drivers\Imagick\Modifiers;
use Intervention\Image\Interfaces\FrameInterface;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
class ResizeModifier implements ModifierInterface
{
protected $width;
protected $height;
public function __construct(int $width, int $height)
{
$this->width = $width;
$this->height = $height;
}
public function apply(ImageInterface $image): ImageInterface
{
foreach ($image as $frame) {
$frame->getCore()->scaleImage($this->width, $this->height);
}
return $image;
}
}