title: Codeigniter image manipulation class rotates image during resize
body: <p>I'm using Codeigniter's image manipulation library to re-size an uploaded image to three sizes, small, normal and large. </p>
  
  <p>The re-sizing is working great. However, if I'm resizing a vertical image, the library is rotating the image so it's horizontal. </p>
  
  <p>These are the config settings I have in place:</p>
  
  <pre><code>     $this-&gt;resize_config['image_library'] = 'gd2';
       $this-&gt;resize_config['source_image'] = $this-&gt;file_data['full_path'];
       $this-&gt;resize_config['maintain_ratio'] = TRUE;
  
       // These change based on the type (small, normal, large)
       $this-&gt;resize_config['new_image'] = './uploads/large/'.$this-&gt;new_file_name.'.jpg';
       $this-&gt;resize_config['width'] = 432;
       $this-&gt;resize_config['height'] = 288;
  </code></pre>
  
  <p>I'm not setting the master_dim property because the default it set to auto, which is what I want. </p>
  
  <p>My assumption is that the library would take a vertical image, see that the height is greater than the width and translate the height/width config appropriately so the image remains vertical. </p>
  
  <p>What is happening (apparently) is that the library is rotating the image when it is vertical and sizing it per the configuration. </p>
  
  <p>This is the code in place I have to do the actual re-sizing:</p>
  
  <pre><code>        log_message('debug', 'attempting '.$size.' photo resize');
          $this-&gt;CI-&gt;load-&gt;library('image_lib');
          $this-&gt;CI-&gt;image_lib-&gt;initialize($this-&gt;resize_config);
          if ($this-&gt;CI-&gt;image_lib-&gt;resize())
          {
                $return_value = TRUE;
                log_message('debug', $size.' photo resize successful');
          }
          else
          {
              $this-&gt;errors[] = $this-&gt;CI-&gt;image_lib-&gt;display_errors();
              log_message('debug', $size.' photo resize failed');
          }
          $this-&gt;CI-&gt;image_lib-&gt;clear();
          return $return_value;
  </code></pre>
  
  <p>EDIT </p>
  
  <p>I think the problem may be from the upload library. When I get the image_height and image_width back from the upload, the width seems to be larger even though I uploaded a vertical image. </p>
  
  <p>This is a portion of the code I'm using to upload the photo:</p>
  
  <pre><code>     $this-&gt;upload_config['allowed_types'] = 'jpg|jpeg';
       $this-&gt;upload_config['max_size']  = '2000';
       $this-&gt;upload_config['max_width']  = '0';
       $this-&gt;upload_config['max_height']  = '0';
       $this-&gt;upload_config['upload_path'] = './uploads/working/';
  
  
       $this-&gt;CI-&gt;load-&gt;library('upload', $this-&gt;upload_config);
       if ($this-&gt;CI-&gt;upload-&gt;do_upload($this-&gt;posted_file))
       {
           $this-&gt;file_data = $this-&gt;CI-&gt;upload-&gt;data();
           $return_value = TRUE;
           log_message('debug', 'upload successful');
       }
  </code></pre>
  
  <p>I added some logging to check the values:</p>
  
  <pre><code>     $this-&gt;is_vertical = $this-&gt;file_data['image_height'] &gt; $this-&gt;file_data['image_width'];
       log_message('debug', 'image height:'.$this-&gt;file_data['image_height']);
       log_message('debug', 'image width:'.$this-&gt;file_data['image_width']);
       if ($this-&gt;is_vertical)
       {
           $this-&gt;resize_config['master_dim'] = 'height';
       }
       else
       {
           $this-&gt;resize_config['master_dim'] = 'width';
       }
      log_message('debug', 'master_dim setting:'.$this-&gt;resize_config['master_dim']); 
  </code></pre>
  
  <p>These are the results of the log: </p>
  
  <p>DEBUG - 2010-03-16 18:35:06 --> image height:1536
  DEBUG - 2010-03-16 18:35:06 --> image width:2048
  DEBUG - 2010-03-16 18:35:06 --> master_dim setting:width</p>
  
  <p>Looking at the image in photoshop, these are the dimensions: </p>
  
  <p>height: 2048
  width: 1536</p>
  
  <p>Anyone know what might be causing the upload library to do this?</p>