diff --git a/src/Drivers/Vips/VipsDriver.php b/src/Drivers/Vips/VipsDriver.php index 620d125..d1743ea 100644 --- a/src/Drivers/Vips/VipsDriver.php +++ b/src/Drivers/Vips/VipsDriver.php @@ -357,7 +357,16 @@ public function image(): Image public function resize(int $width, int $height, array $constraints): static { - // TODO: Implement resize() method. + $resized = $this->getSize()->resize($width, $height, $constraints); + + $widthRatio = $resized->width / $this->image->width; + $heightRatio = $resized->height / $this->image->height; + + $this->image = $this->image->resize($widthRatio, [ + 'vscale' => $heightRatio + ]); + + return $this; } public function width(int $width, array $constraints = []): static diff --git a/tests/__snapshots__/ResizeTest__it_can_resize_an_image_with_data_set_dataset_vips__1.png b/tests/__snapshots__/ResizeTest__it_can_resize_an_image_with_data_set_dataset_vips__1.png new file mode 100644 index 0000000..e8e77cd Binary files /dev/null and b/tests/__snapshots__/ResizeTest__it_can_resize_an_image_with_data_set_dataset_vips__1.png differ