简体   繁体   English

如何在codeigniter中调整图像大小?

[英]how to resize image in codeigniter?

I trying to resize the image uploaded by user without cropping it. 我试图调整用户上传的图像的大小,而不会裁剪图像。 For that I am using following code. 为此,我正在使用以下代码。

$config['image_library'] = 'gd2';
    $config['source_image'] = './uploads/'.$name.'.jpg';
    $config['new_image']    = './uploads/'.$name.'.jpg';
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width']     = 75;
    $config['height']   = 50;
    $this->image_lib->resize();
    $config['new_image']    = './uploads/'.$name.'.jpg';
    $config['width']     = 1000;
    $config['height']   = 400;
    $this->image_lib->initialize($config);
    $this->image_lib->resize();

but the problem is that it does not give me the image size 1000x400. 但问题是它没有给我图像尺寸1000x400。 it gives me the image with size 534x400. 它给我的尺寸为534x400。 Is there any way to overcome this problem? 有什么办法可以克服这个问题?

Change your $config['maintain_ratio'] = TRUE; 更改$config['maintain_ratio'] = TRUE; to $config['maintain_ratio'] = FALSE; 为$ config ['maintain_ratio'] = FALSE;

Change this property to 将此属性更改为

$config['maintain_ratio'] = FALSE; $ config ['maintain_ratio'] = FALSE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM