title: How to use ImageMagick in CodeIgniter
body: <p>I have a controller which can upload images. Now gd2 library works perfectly except for big images. So I want to use ImageMagick for this. But I can't get it working. I use mamp for my localhost.</p>
  <p>This is my code:</p>
  <pre><code>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-&gt;load-&gt;library('upload', $config);    
          if ( ! $this-&gt;upload-&gt;do_upload())
          {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
          }   
          $datap = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
          
          $id = $this-&gt;input-&gt;post('id');
      
          $gallery_path = realpath(APPPATH . '/../uploads');
  
          $upload_data = $this-&gt;upload-&gt;data();
      
          $this-&gt;load-&gt;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-&gt;image_lib-&gt;clear();
          $this-&gt;image_lib-&gt;initialize($config);
          $this-&gt;upload-&gt;display_errors();
          $this-&gt;image_lib-&gt;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-&gt;image_lib-&gt;clear();
          $this-&gt;image_lib-&gt;initialize($config);
          $this-&gt;image_lib-&gt;crop();
      
  
          $thumb = $this-&gt;upload-&gt;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-&gt;image_lib-&gt;clear();
          $this-&gt;image_lib-&gt;initialize($config);
          $this-&gt;image_lib-&gt;resize();
          $medium = $this-&gt;upload-&gt;data();
          $mediumname = $medium['raw_name'] . '_medium'. $medium['file_ext'];
          
      $data = array(
          'fk_land' =&gt; $this-&gt;input-&gt;post('landid'),
          'titel' =&gt; $this-&gt;input-&gt;post('titel'),
          'period' =&gt; $this-&gt;input-&gt;post('period'),
          'size' =&gt; $this-&gt;input-&gt;post('size'),
          'info' =&gt; $this-&gt;input-&gt;post('info'),
          'region' =&gt; $this-&gt;input-&gt;post('region'),
          'cat_id' =&gt; $this-&gt;input-&gt;post('catsculp'),
          'color' =&gt; $this-&gt;input-&gt;post('color'),
          'order' =&gt; $this-&gt;input-&gt;post('landtoevoegen'),
          'gallery_name' =&gt; $this-&gt;input-&gt;post('painter'),
          'thumb_img' =&gt; $thumbname,
          'medium_img' =&gt; $mediumname
      
      );
          
          if( $datap['upload_data']['orig_name'] != &quot;&quot; ) $data['gallery_img'] = $datap['upload_data']['orig_name'];
          $this-&gt;Cms_model-&gt;voegfototoe($data);
          redirect('home#toevoegen','refresh');   
      }
  </code></pre>