简体   繁体   中英

How to change image size from database in codeigniter?

I have image folder path from database as $banner_image_base :

/asset/images/promotion_banner/banner/2/2/2_xlIe1qJh_s300.jpg

From /asset/images/promotion_banner/ is the default folder.

banner is promotion_type , the frist one of 2 is promotion_banner_position , the second one of 2 is promotion_id and the last one as the image 2_xlIe1qJh_s300.jpg

I want trying to change the image size if the promotion_banner_position is changed

In my html there is 4 promotion_banner_position as 1 , 2 , 3 , and 4 . If the promotion_banner_position is change to be 1 the size should be :

width = 160px; height 940px

And if promotion_banner_position 1 change to be 2 , 3 or 4 the size should be :

width = 320px; height 300px

Guys is that possible to change the image' size, that has been upload to database? thank you (:

  1. Check whether the target directory have write permission.
  2. Check you didn't load the image_lib library twice.

and this is the code which I am using currently

$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = "Mention your source location here";
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['height']   = "New Width";
$config['width'] = "New Height";
$config['new_image'] = "destination location";//you should have write permission here..
$this->image_lib->initialize($config);
$this->image_lib->resize();

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