Class: Nanoc::Filters::ImageCompressor
- Inherits:
-
Nanoc::Filter
- Object
- Nanoc::Filter
- Nanoc::Filters::ImageCompressor
- Defined in:
- lib/nanoc/filters/image_compressor.rb
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Method Summary collapse
-
#run(filename, params = {}) ⇒ void
Compresses the content with Sprockets::ImageCompressor.
Instance Method Details
#run(filename, params = {}) ⇒ void
This method returns an undefined value.
Compresses the content with Sprockets::ImageCompressor.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nanoc/filters/image_compressor.rb', line 19 def run(filename, params={}) io = ImageOptim.new(params.merge(:threads => false)) result = io.optimize_image(filename) path = result ? result.to_s : filename FileUtils.cp path, output_filename # ensure the output permissions match the input in_mode = File.stat(filename).mode & 0777 out_mode = File.stat(output_filename).mode & 0777 File.chmod(in_mode, output_filename) if in_mode != out_mode end |