Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在CodeIgniter中使用ImageMagick_Php_Codeigniter_File Upload - Fatal编程技术网

Php 如何在CodeIgniter中使用ImageMagick

Php 如何在CodeIgniter中使用ImageMagick,php,codeigniter,file-upload,Php,Codeigniter,File Upload,我有一个可以上传图像的控制器。现在gd2库除了大图像外工作得很好。所以我想用ImageMagick来做这个。但我不能让它工作。我使用mamp作为本地主机 这是我的代码: function voegfotostoe() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '0';

我有一个可以上传图像的控制器。现在gd2库除了大图像外工作得很好。所以我想用ImageMagick来做这个。但我不能让它工作。我使用mamp作为本地主机

这是我的代码:

function voegfotostoe()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '0';
        $config['max_width']  = '0';
        $config['max_height']  = '0';
        $this->load->library('upload', $config);    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
        }   
        $datap = array('upload_data' => $this->upload->data());
        
        $id = $this->input->post('id');
    
        $gallery_path = realpath(APPPATH . '/../uploads');

        $upload_data = $this->upload->data();
    
        $this->load->library('image_lib');
    
        /* Size 350px x 300px */
        $config['image_library'] = 'ImageMagick';
        $config['library_path'] = '/usr/bin/';
        $config['source_image'] = $upload_data['full_path'];
        $config['new_image'] = $gallery_path . '/thumbs';
        $config['create_thumb'] = FALSE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 350;
        $config['height'] = 300;

        $this->image_lib->clear();
        $this->image_lib->initialize($config);
        $this->upload->display_errors();
        $this->image_lib->resize();
    
    
        $config['image_library'] = 'ImageMagick';
        $config['library_path'] = '/usr/bin/';
        $config['source_image'] = $upload_data['file_path'] . 'thumbs/' . $upload_data['orig_name'];
        $config['new_image'] = $gallery_path . '/vierkant';
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = FALSE;
        $config['width'] = 200;
        $config['height'] = 200;

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

        $thumb = $this->upload->data();
        $thumbname = $thumb['raw_name'] . $thumb['file_ext'];
    
        /* Size 600px X 600px */
    
        $config['image_library'] = 'ImageMagick';
        $config['library_path'] = '/usr/bin/';
        $config['source_image'] = $upload_data['full_path'];
        $config['new_image'] = $gallery_path . '/medium';
        $config['thumb_marker'] = '_medium';
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 500;
        $config['height'] = 500;

        $this->image_lib->clear();
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        $medium = $this->upload->data();
        $mediumname = $medium['raw_name'] . '_medium'. $medium['file_ext'];
        
    $data = array(
        'fk_land' => $this->input->post('landid'),
        'titel' => $this->input->post('titel'),
        'period' => $this->input->post('period'),
        'size' => $this->input->post('size'),
        'info' => $this->input->post('info'),
        'region' => $this->input->post('region'),
        'cat_id' => $this->input->post('catsculp'),
        'color' => $this->input->post('color'),
        'order' => $this->input->post('landtoevoegen'),
        'gallery_name' => $this->input->post('painter'),
        'thumb_img' => $thumbname,
        'medium_img' => $mediumname
    
    );
        
        if( $datap['upload_data']['orig_name'] != "" ) $data['gallery_img'] = $datap['upload_data']['orig_name'];
        $this->Cms_model->voegfototoe($data);
        redirect('home#toevoegen','refresh');   
    }
更换这些线路:

$config['source_image']=site_url().'marcella-resources/front/img/M24CPP_x200/SBase1.jpg'; $config['new_image']=site_url().'marcella-resources/front/test/SBase1_copy.jpg'

以下几行:

$config['source_image']='marcella resources/front/img/M24CPP_x200/SBase1.jpg';
$config['new_image']='marcella resources/front/test/SBase1_copy.jpg'

确保您对
$gallery\u path具有写入权限/拇指“
$gallery\u path”/vierkant的
和其他FoldersPermission是777,它可以与gd2库一起使用,但不能与ImageMagick一起使用