0

我需要调整图像大小以适合 64x64 缩略图。我在做什么?我将调整宽度和高度设置为 64 像素。如果我设置 $config['maintain_ratio'] = false,图像会失去比例。我做了什么:我设置 $config['maintain_ratio'] = TRUE; 和 $config['master_dim'] = 'width'; 现在宽度始终为 64 像素,但高度更大。我必须以某种方式将图像高度从底部裁剪为 64px。我怎样才能做到这一点?我尝试设置裁剪功能,但失败了。也许还有另一种解决方案...我的调整大小功能

private function resize($up_data) {
        $config['image_library']  = 'gd2';
        $config['source_image']   = $up_data['full_path'];   
        $config['new_image']      = './images/autoriaithumb/';
        $config['create_thumb']   = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['thumb_marker'] = '_thumb';
        $config['width']          = 64;
        $config['height']         = 64;
        $config['quality']        = 100;
        $config['master_dim'] = 'width';

        $this->image_lib->initialize($config);

        $this->image_lib->resize();

}

4

1 回答 1

0

尝试这个

将“上传配置”定义为 $image_config 并将您的裁剪配置....定义为 $config

$this->load->library('upload', $image_config);
if ($this->upload->do_upload()) {
  $this->load->library('image_lib',$config); 
  $this->image_lib->resize();
}
于 2015-01-13T12:03:14.190 回答