I am using both PHP imagick and PHP vips library for image operations. I am working on image resize operation. For imagick I am using resizeImage() function and for vips I am using resize() function. But the output of both the image are different for same height and width. I want to same output for vips. Here I add my code which I am using for vips. I want same result for vips also, which I got into imagick
<!-- Imagick Code -->
$img = new Imagick($ipFile);
$img->resizeImage(1000, 1000, Imagick::FILTER_LANCZOS, 1, true);
$img->writeimage($opFile);
<!-- VIPS Code -->
$im = Vips\Image::newFromFile($ipFile);
$im = $im->resize($ratio, ['kernel' => 'lanczos2']);
$im->writeToFile($opFile);
Don't use
resize
with php-vips unless you really have to. You'll get better quality, better speed and lower memory use withthumbnail
.The
thumbnail
operation combines load and resize in one, so it can exploit tricks like shrink-on-load. It knows about transparency, so it'll resize PNGs correctly. It also knows about vector formats like PDF and SVG and will size them in the best way.Try:
Benchmark:
nina.jpg
is a 6k x 4k RGB JPG image.resize
takes 390ms and 61MB of memorythumbnail
takes 160ms and 50MB of memoryQuality will be the same in this case.