The latest in my of “shouldn’t this be better covered in Google and docs if people really use CarrierWave?”-series. Creating a custom thumbnail processor in Carrierwave is pretty straightforward, but not from any search query I could construct. The gist:
class MyUploader < CarrierWave::Uploader::Base
version :custom_thumbnail do
process :some_fancy_processing
end
def some_fancy_processing
# Here our context is the CarrierWave::Uploader object, so we have its full
# assortment of methods at our disposal. Let's say we want to open an image with
# openCV and smooth it out. That would look something like:
cv_image = OpenCV::CvMat.load *([ self.full_cache_path ]) # See past blog post on the origins of full_cache_path
cv_image.smooth(5,5)
# The key to telling CW what data this thumb should use is to save our output to
# the current_path of the Uploader, a la
cv_image.save_image(self.current_path)
end
end
Just call #custom_thumbnail.url on your Uploader instance, and you should get the path to the custom result you created.
Using this framework you should be able to get CW to perform whatever sort of custom image processing you want. Thanks to these fellows for helping me decode the #current_path magic here.