mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 08:09:54 +02:00
ResizeModifier
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
28
src/Drivers/Imagick/Modifiers/ResizeModifier.php
Normal file
28
src/Drivers/Imagick/Modifiers/ResizeModifier.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user