php - 使用 imagick 驱动程序调整为小图像的图像会产生大文件大小

标签 php image laravel-5 imagick intervention

我正在调整项目中大图像的大小以创建缩略图。这是一个例子:

原始图像 (1160 x 773): Original Image (1160 x 773)

缩略图(400 x 266): Thumbnail (400 x 266)

问题是,大图像是 732kb,我认为这是可以理解的,因为它的尺寸很大,但第二个图像仍然是 573kb。

这是正常现象还是有问题?

这是我调整大小的代码:

\Intervention\Image\Facades\Image::make($originalPath)
    ->resize($resized_width, $resized_height, function($constraint){
        $constraint->aspectRatio();
        $constraint->upsize();
    })
    ->save($thumbnailPath, 85);

最佳答案

尝试此代码,您将获得具有宽高比的小尺寸图像。

$configpath = 'Path of destination';
$width      = ($width)?$width:200;
$height     = ($height)?$height:200;
$img = Image::canvas($width, $height);
$image = Image::make($path)->resize($width, $height, function ($c) {
        $c->aspectRatio();
        $c->upsize();
});
// insert resized image centered into background
$img->insert($image, 'center');
$img->save($configpath.$width.'x'.$height.'_'.$filename);

关于php - 使用 imagick 驱动程序调整为小图像的图像会产生大文件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36254333/

相关文章:

php - 在 MySQL 中搜索字符串 WHERE string LIKE string(括在括号中)

Android - 如何压缩或缩小图像?

android - iText,将图像添加到 pdf 时出现 FileNotFoundException

php - Laravel 5 M2M 多态关系未设置?

laravel - 运行 Laravel 5 迁移时如何提示输入数据库密码

php - 使用下拉菜单进行编辑 - Codeigniter

php - Yahoo Placefinder Geocoding 随机停止工作......他们现在不支持了吗?

laravel - 在 Laravel 5.3 中创建自定义异常类和自定义处理程序类

php - 混淆了bindValue() 和bindParam() 之间的关系吗?

python - 检测4个有趣的像素