title: Stop paperclip from cropping and resizing before other parameters
body: <p>I am using Paperclip to store my image, and I want to create a cropped/rotated image as a thumbnail. Here is the PROPER command that Paperclip should be running:</p>
  
  <pre><code>convert [file].jpg -gravity center -distort SRT -30 -quality 100 -antialias -flatten -background white -unsharp 0.3x0.3+5+0 -crop 433x433+69+88 +repage -resize "300x300&gt;" [file].jpg
  </code></pre>
  
  <p>This produces the result I want. I've tested it directly on my pc having installed imagemagick. However looking at the logs on my server, the order of these arguments is different. Paperclip wants to a) Put the <code>-resize "300x300&gt;"</code> command FIRST, THEN puts <code>-crop 433x433+69+88</code> SECOND, and THEN put the rest of the arguments afterwards. This changes the look of the final image! Not what I want. Here's what it outputs in the logs:</p>
  
  <pre><code>convert [file].jpg -auto-orient -resize "300x300&gt;" -crop 433x433+69+88 +repage -gravity center -distort SRT -30 -quality 100 -antialias -flatten -background white -unsharp 0.3x0.3+5+0 [file].jpg
  </code></pre>
  
  <p>...and here's my config in my model:</p>
  
  <p><strong>Wine.rb</strong></p>
  
  <pre><code>has_attached_file :photo, :styles =&gt; {
                      :thumb =&gt; {
                      :geometry =&gt; "300x300&gt;",
                      :format =&gt; :jpg,
                      :processors =&gt; [:cropper, :recursive_thumbnail],
                      :thumbnail =&gt; :croppable
                      },
                      :general =&gt; ["150x375", :jpg],
                      :show =&gt; ["x425", :jpg],
                      :croppable =&gt; ["1200x1200&gt;", :jpg]
          },
          :url  =&gt; "/assets/wines/:style/:wine_name",
          :path =&gt; ":rails_root/public:url",
          :default_url =&gt; ":wine_default",
          :default_path =&gt; ":rails_root/public:wine_default",
          :default_style =&gt; :show,
          :convert_options =&gt; {
              :thumb =&gt; '-gravity center -distort SRT -30',
              :croppable =&gt; '-gravity center -extent 1200x1200',
              :general =&gt; '-gravity center -extent 150x375 -quality 95',
              :all =&gt; '-quality 100 -antialias -flatten -background white -unsharp 0.3x0.3+5+0'
          },
          :processors =&gt; [:thumbnail, :compression]
  </code></pre>
  
  <p>Basically it runs convert.exe in this order: [:geometry][:transformations][:convert_options].</p>
  
  <p>How do I get things in the order I want?</p>
  
  <p><strong>recursive_thumbnail.rb</strong> -- for running the :thumb thumbnail generation off of :croppable and not the original file (because of horizontal padding issues when cropping)</p>
  
  <pre><code>module Paperclip
      class RecursiveThumbnail &lt; Thumbnail
      def initialize file, options = {}, attachment = nil
          super Paperclip.io_adapters.for(attachment.styles[options[:thumbnail] || :original]), options, attachment
      end
      end
  end
  </code></pre>
  
  <p><strong>cropper.rb</strong></p>
  
  <pre><code>module Paperclip
      class Cropper &lt; Thumbnail
      def transformation_command
          if crop_command
          super.join(' ').sub(/ -crop \S+/, '').split(' ') + crop_command
          else
          super
          end
      end
  
      def crop_command
          target = @attachment.instance
          if target.cropping?
          ["+repage", "-crop", "#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}", "+repage"]
          end
      end
      end
  end
  </code></pre>