Class: Sprockets::ImageCompressor::JpgCompressor
- Defined in:
- lib/sprockets/image_compressor/jpg_compressor.rb
Instance Method Summary collapse
- #compress(content) ⇒ Object
-
#initialize ⇒ JpgCompressor
constructor
A new instance of JpgCompressor.
Methods inherited from Base
Constructor Details
#initialize ⇒ JpgCompressor
Returns a new instance of JpgCompressor.
6 7 8 |
# File 'lib/sprockets/image_compressor/jpg_compressor.rb', line 6 def initialize @name = "convert" end |
Instance Method Details
#compress(content) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sprockets/image_compressor/jpg_compressor.rb', line 10 def compress(content) compressed_jpg_data = "" Tempfile.open ["file", ".jpg"] do |file| file.binmode file.write content file.close out = `#{binary_path} -strip -interlace Plance #{file.path} 2>&1` compressed_jpg_data = IO.binread(file.path) end compressed_jpg_data end |