title: Getting width and height of image in model in the Ruby Paperclip GEM
body: <p>Trying to get the width and height of the uploaded image while still in the model on the initial save.</p>
  
  <p>Any way to do this?</p>
  
  <p>Here's the snippet of code I've been testing with from my model. Of course it fails on "instance.photo_width".</p>
  
  <pre><code>has_attached_file :photo,
                        :styles =&gt; {
                        :original  =&gt; "634x471&gt;",
                        :thumb =&gt; Proc.new { |instance|                       
                                    ratio = instance.photo_width/instance.photo_height
                                    min_width   = 142
                                    min_height  = 119
                                    if ratio &gt; 1
                                      final_height  = min_height
                                      final_width   = final_height * ratio
                                    else
                                      final_width   = min_width
                                      final_height  = final_width * ratio
                                    end
                                    "#{final_width}x#{final_height}" 
                                  }
                      }, 
                      :storage =&gt; :s3,
                      :s3_credentials =&gt; "#{RAILS_ROOT}/config/s3.yml",
                      :path =&gt; ":attachment/:id/:style.:extension",
                      :bucket =&gt; 'foo_bucket' 
  </code></pre>
  
  <p>So I'm basically trying to do this to get a custom thumbnail width and height based on the initial image dimensions.</p>
  
  <p>Any ideas?</p>