title: Rails and Carrierwave, save versions with different extensions
body: <p>What i need for performance reasons, is that the thumb versions keeps the png format and extension. Format seems to be converting right, but it keeps saving the images with .jpg extensions.</p>
  
  <p>So i have this code for my user avatar:</p>
  
  <pre><code>class UserAvatarUploader &lt; CarrierWave::Uploader::Base
  
      include CarrierWave::MiniMagick
  
      version :large do
          process resize_to_fit: [ 600, 600 ], convert: 'jpg'
      end
  
      version :small, from_version: :large do
          process resize_to_fill: [ 216, 216 ], convert: 'jpg'
      end
  
      version :thumb, from_version: :small do
          process resize_to_fill: [ 80, 80 ], convert: 'png'
      end
  
      version :tiny, from_version: :thumb do
          process resize_to_fill: [ 50, 50 ], convert: 'png'
      end
  
      def filename
          "#{secure_token}.#{file.extension}" if original_filename.present?
      end
  
      protected
  
      def secure_token
          var = :"@#{mounted_as}_secure_token"
          model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
      end
  
  end
  </code></pre>
  
  <p>And it saves the images like this:</p>
  
  <ul>
  <li>cbc9418c-ffaa-49da-a530-f940d3da2868.jpg</li>
  <li>large_cbc9418c-ffaa-49da-a530-f940d3da2868.jpg</li>
  <li>small_cbc9418c-ffaa-49da-a530-f940d3da2868.jpg</li>
  <li>thumb_cbc9418c-ffaa-49da-a530-f940d3da2868.jpg</li>
  <li>tiny_cbc9418c-ffaa-49da-a530-f940d3da2868.jpg</li>
  </ul>
  
  <hr>
  
  <p>Even when i change the entire code to:</p>
  
  <pre><code>class UserAvatarUploader &lt; CarrierWave::Uploader::Base
  
      include CarrierWave::MiniMagick
  
      version :large do
          process resize_to_fit: [ 600, 600 ], convert: :jpg
      end
  
      version :small do
          process resize_to_fill: [ 216, 216 ], convert: :jpg
      end
  
      version :thumb do
          process resize_to_fill: [ 80, 80 ], convert: :png
      end
  
      version :tiny do
          process resize_to_fill: [ 50, 50 ], convert: :png
      end
  
  end
  </code></pre>
  
  <p>It keeps saving al the images with jpg extension, <strong>WTF</strong>.</p>
  
  <hr>
  
  <p><strong>I am going crazy with this, any suggestions?</strong></p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have tried the next code</p>
  
  <pre><code>class UserAvatarUploader &lt; CarrierWave::Uploader::Base
  
      include CarrierWave::MiniMagick
  
      version :large do
          process resize_to_fit: [ 600, 600 ], convert: :jpg
      end
  
      version :small do
          process resize_to_fill: [ 216, 216 ], convert: :jpg
      end
  
      version :thumb do
          process resize_to_fill: [ 80, 80 ], convert: :png
      end
  
      version :tiny do
          process resize_to_fill: [ 50, 50 ], convert: :png
      end
  
      def filename
      "#{secure_token}.#{file.extension}" if original_filename.present?
      end
  
      protected
  
      def secure_token
          var = :"@#{mounted_as}_secure_token"
          model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
      end
  
  end
  </code></pre>
  
  <p>And it uploads the correct images to S3, but then user.avatar saves all versions in .jpg <strong>WTF!!!!</strong>. It is really weird what's happening now...</p>
  
  <p>Console:</p>
  
  <pre><code>&gt; user = User.find(id)
  &gt; user.avatar.recreate_versions!
  &gt; user.save!
  &gt; user.avatar.large.url
  =&gt; "http://bucket.s3.amazonaws.../large_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  &gt; user.avatar.small.url
  =&gt; "http://bucket.s3.amazonaws.../small_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  &gt; user.avatar.thumb.url
  =&gt; "http://bucket.s3.amazonaws.../thumb_96a1f5a4-cf07-490f-9711-618e04071950.png"
  &gt; user.avatar.tiny.url
  =&gt; "http://bucket.s3.amazonaws.../tiny_96a1f5a4-cf07-490f-9711-618e04071950.png"
  &gt; reload!
  &gt; user = User.find(id)
  &gt; user.avatar.large.url
  =&gt; "http://bucket.s3.amazonaws.../large_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  &gt; user.avatar.small.url
  =&gt; "http://bucket.s3.amazonaws.../small_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  &gt; user.avatar.thumb.url
  =&gt; "http://bucket.s3.amazonaws.../thumb_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  &gt; user.avatar.tiny.url
  =&gt; "http://bucket.s3.amazonaws.../tiny_96a1f5a4-cf07-490f-9711-618e04071950.jpg"
  </code></pre>
  
  <p><strong>I HATE YOU CARRIERWAVE</strong></p>