Module: Mozjpeg
- Defined in:
- lib/mozjpeg.rb,
lib/mozjpeg/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
- .cjpeg_path ⇒ Object
-
.compress(src, dst, options = {}) ⇒ Object
TODO improve Accepts instances of File.
- .supported? ⇒ Boolean
Class Method Details
.cjpeg_path ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mozjpeg.rb', line 10 def self.cjpeg_path base_path = File.(File.join(__dir__, '../vendor/mozjpeg')) mozjpeg_path = begin if OS.windows? 'win/cjpeg.exe' elsif OS.mac? && OS.bits == 64 'darwin/cjpeg' elsif OS.linux? && OS.bits == 64 'linux/cjpeg' else raise "MozJPEG for your platform was not found." end end File.join(base_path, mozjpeg_path) end |
.compress(src, dst, options = {}) ⇒ Object
TODO improve Accepts instances of File
30 31 32 33 |
# File 'lib/mozjpeg.rb', line 30 def self.compress(src, dst, = {}) args = .fetch(:arguments, '-quality 70 -quant-table 2 -notrellis') return `"#{Mozjpeg.cjpeg_path}" #{args} -outfile "#{dst.path}" "#{src.path}" 2>&1` end |
.supported? ⇒ Boolean
6 7 8 |
# File 'lib/mozjpeg.rb', line 6 def self.supported? cjpeg_path rescue false end |