This runs provides an .optim job for dragonfly and also adds the .optim job into .thumb
This requires you have the 'image_optim' gem and it's dependencies.
This runs provides an .optim job for dragonfly and also adds the .optim job into .thumb
This requires you have the 'image_optim' gem and it's dependencies.
| require 'dragonfly/image_optim_processor' | |
| app = Dragonfly[:images] | |
| app.configure do |c| | |
| c.processor.register(ImageOptimProcessor) | |
| c.job :optim do | |
| process :optim | |
| end | |
| c.job :thumb do |geometry, format| | |
| process :thumb, geometry | |
| process :optim | |
| encode format if format | |
| end | |
| end |
| class ImageOptimProcessor | |
| def optim(temp_object) | |
| io = ImageOptim.new | |
| optimized = io.optimize_image(temp_object.path) | |
| optimized.nil? ? temp_object : optimized | |
| end | |
| end |
I had to tweak it a bit for last version of ImageOptim and Dragonfly, see : https://gist.github.com/bobbus/8913693
Very helpful gist! I'm wondering why you have optim before encode?
I would assume that optim would be the last thing to be done.