title: CodeIgniter Image Manipulation (Resize & Watermark)
body: <p>I'm hoping someone can help me. I'm trying to upload an image via a form, resize it to 600px, create a 100px thumbnail and then add a watermark image to the 600px version, but the code below is just creating two versions of the original image.</p>
  
  <pre><code>$image = $this-&gt;upload-&gt;data();
  $resized = base_url()."images/artwork/".$image['orig_name'];
  
  //Create 600px version
  $config = array();
  $config['source_image'] = $resized;
  $config['image_library'] = 'gd2';
  $config['maintain_ratio'] = TRUE;
  $config['width'] = 600;
  $config['height'] = 600;
  $this-&gt;image_lib-&gt;initialize($config);
  $this-&gt;image_lib-&gt;resize();
  $this-&gt;image_lib-&gt;clear();
  unset($config);
  
  //Add watermark to 600px version
  $config = array();
  $config['source_image'] = $resized;
  $config['image_library'] = 'gd2';
  $config['wm_type'] = 'overlay';
  $config['wm_overlay_path'] = './images/logo.gif';
  $config['wm_vrt_alignment'] = 'middle';
  $config['wm_hor_alignment'] = 'center';
  $this-&gt;image_lib-&gt;initialize($config);
  $this-&gt;image_lib-&gt;watermark();
  $this-&gt;image_lib-&gt;clear();
  unset($config);
  
  //Create 100px unwatermarked thumbnail
  $config = array();
  $config['source_image'] = $resized;
  $config['image_library'] = 'gd2';
  $config['maintain_ratio'] = TRUE;
  $config['width'] = 100;
  $config['height'] = 100;
  $this-&gt;image_lib-&gt;initialize($config);
  $this-&gt;image_lib-&gt;resize();
  $this-&gt;image_lib-&gt;clear();
  unset($config);
  $thumbnail = base_url()."images/artwork/".$image['raw_name']."".$image['file_ext'];
  
  echo "&lt;a href=\"".$resized."\"&gt;&lt;img src=\"".$thumbnail."\" /&gt;&lt;/a&gt;";
  </code></pre>