CodeIgniter crop() without maintain_ration

天大地大妈咪最大 提交于 2019-12-08 13:23:46

问题


I have this function above witch even maintain_ration set false, cutting with this proportion. In this case the result is an image with 150x113px, because the original image has 400x300.

 function do_crop() {

    $config = array(
   'image_library' => 'gd2',
   'source_image' => realpath(APPPATH . '../upload_img/solg6.jpg'), 
   'new_image' => $this->gallery_path_url . 'thumbaaa.jpg',
   'maintain_ration' => false, 
   'width' => 150,
   'height' => 150,
     'x_axis' => 20,
   'y_axis' => 20
  );

  $this->load->library('image_lib');
  $this->image_lib->initialize($config);
  if ( ! $this->image_lib->crop())
  {
      echo $this->image_lib->display_errors();
  }
  $this->image_lib->clear();
 } 

I just want crop without ratio.


回答1:


I think the problem is that you mispelled the setting name in the configuration. It is "maintain_ratio", not "maintain_ration".

The default value for this setting is true and you are not overriding it. The image is being cropped with the ratio maintained.



来源:https://stackoverflow.com/questions/2436378/codeigniter-crop-without-maintain-ration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!