what I want to do is save the website URL using a full-size snapshot via IMGKit. In one of the views, I also want to have a thumbnail version of the snapshot. I use a carrier wave to associate a snapshot with a MiniMagick object to manipulate it, the problem is that it generates a thumbnail image but does not resize it, as a result I have two full-size snapshots, one of which is prefixed "thumb".
I have this model in rails
class Webpage mount_uploader :snapshot, SnapshotUploader field :url, type: String field :title, type: String after_create :get_snapshot private def get_snapshot file = Tempfile.new(["#{id}#{title}".downcase, '.jpg'], 'tmp', :encoding => 'ascii-8bit') image = IMGKit.new(url, quality: 90).to_jpg file.write(image) file.flush self.snapshot= file self.save file.unlink end end
And I have this in Uploader to create a thumbnail:
class SnapshotUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick version :thumb do process resize_to_fill: [180, 180] end end
Using the console, I tried MiniMagick to resize the image and it works fine, I don't know what is going on. I am not sure that I am doing it right, so any help would be appreciated. Thanks.
John source share