【问题标题】:How to change image size from database in codeigniter?如何在codeigniter中更改数据库中的图像大小?
【发布时间】:2016-12-18 23:05:17
【问题描述】:

我有来自数据库的图像文件夹路径为 $banner_image_base :

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

来自/asset/images/promotion_banner/ 是默认文件夹。

bannerpromotion_type2的第一个是promotion_banner_position2的第二个是promotion_id,最后一个是image2_xlIe1qJh_s300.jpg

如果promotion_banner_position 发生更改,我想尝试更改图像大小

在我的 html 中有 4 promotion_banner_position1234。如果promotion_banner_position 更改为1,则大小应为:

width = 160px; height 940px

如果 promotion_banner_position 1 更改为 234,则大小应为:

width = 320px; height 300px

各位,可以更改已上传到数据库的图像大小吗?谢谢(:

【问题讨论】:

    标签: php image codeigniter


    【解决方案1】:
    1. 检查目标目录是否有写权限。
    2. 检查您没有两次加载 image_lib 库。

    这是我目前正在使用的代码

    $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();
    

    【讨论】:

      猜你喜欢
      • 2014-12-14
      • 2019-12-05
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      • 2019-10-31
      相关资源
      最近更新 更多