Codeigniter 代码点火器调整大小()

Codeigniter 代码点火器调整大小(),codeigniter,Codeigniter,我正在使用resize()调整缩略图的大小。我的源图像是1024*768。这是我的配置 $demo= array( 'source_image' => $x['full_path'], 'new_image' => $this->image, 'maintain_ratio' => true, 'create_thumb' =&

我正在使用resize()调整缩略图的大小。我的源图像是1024*768。这是我的配置

 $demo= array(
                  'source_image' => $x['full_path'],
                  'new_image' => $this->image,
                  'maintain_ratio' => true,
                  'create_thumb' => true,
                  'width' => 192,
                  'height' => 92
                );

但我的图像正在调整为123*98。为什么不使用宽度值?

您已经启用了
维护比例
选项,因此CI将尝试创建“尽可能接近目标宽度和高度,同时保留原始纵横比”的缩略图

在您的示例中,图像的尺寸为1024x768,纵横比为1.33854(1024/768)

这对应于使用指定的宽度和高度值的192x143缩略图或123x92缩略图

CI决定123x92更适合(可能基于缩略图的面积)

为什么是123x98?可能是调整大小算法的一些瑕疵(数学舍入错误?)

您需要查看CI代码的详细信息,以获得更精确的答案

脚注
有一些关于CI中图像大小调整的讨论,模块中有一些怪癖:

[quote author="Saete" date="1346125636"]You will not beleive me, 
y had the same problem and y changed the order of configuration parameters 
with the maintain_ratio = true, and it worked :S
I needed to adjust to height:

Didn't work:
$config['width'] = 126;
$config['height'] = 84;
$config['maintain_ratio'] = TRUE;

Worked!
$config['height'] = 84;
$config['width'] = 126;
$config['maintain_ratio'] = TRUE;

Some years later, but it may help someone...[/quote]
显然,参数的顺序会有所不同(这肯定是一个bug)。

参考资料:

好的。我怎么得到123*98?我知道123是从哪里来的,我猜大概是98。你可以调整宽度/高度,使缩略图的纵横比更接近输入图像的纵横比,看看结果是否不同。我做了一些研究,并在Ellis Lab论坛上找到了一个讨论。其他人如何实现他们喜欢的宽度和高度。是否有任何替代图像库功能的方法。图像用户上传将是不同的大小,但我想在我提到的大小缩略图。感谢花时间回答我的问题。