R
R
Rigorbb2016-11-26 16:19:26
PHP
Rigorbb, 2016-11-26 16:19:26

Why does image size increase after resizing in Image Intervention?

Reducing the image size using Image Intervention:

$img = Image::make($image->getPathname());
  $img->widen(1350)->save($this->getNewDirecoryName($folder, $image));

The resolution of the image is reduced by a factor of 2, but for some reason the size grows by a factor of two. Reducing the size can only be achieved by reducing the quality:
$img->widen(1350)->save($this->getNewDirecoryName($folder, $image), 70);

But then the image will be in the soap. Google also tried such exotic options:
$img = Image::make($image->getPathname());
                $img->widen(1350, function($constraint) {
                    $constraint->aspectRatio();
                    $constraint->upsize();
                });
                $canvas = Image::canvas($img->getWidth(), $img->getHeight());
                $canvas->insert($img, 'center');
                $canvas->save($this->getNewDirecoryName($folder, $image));

There is no sense. Tried "gd" and "imagick" drivers. Tell me what could be the problem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AndreiSoroka, 2020-04-02
@AndreiSoroka

The edges are blurred, causing more colors (anti-aliasing).
You can use k-nearest, but then the picture will become square when reduced (without anti-aliasing).
You can also try to reduce the number of colors: https://pngquant.org/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question