简体   繁体   中英

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. it gives me the image with size 534x400. Is there any way to overcome this problem?

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

Change this property to

$config['maintain_ratio'] = FALSE;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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