Class: PaperclipCompression::Png
- Defined in:
- lib/paperclip-compression/png.rb
Constant Summary collapse
- OPTIPNG_DEFAULT_OPTS =
'-o 5'
Instance Method Summary collapse
-
#initialize(file, options = {}) ⇒ Png
constructor
A new instance of Png.
- #make ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(file, options = {}) ⇒ Png
Returns a new instance of Png.
6 7 8 9 10 |
# File 'lib/paperclip-compression/png.rb', line 6 def initialize(file, = {}) super(file, ) @src_path = File.(@file.path) @cli_opts = init_cli_opts(:png, default_opts) end |
Instance Method Details
#make ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/paperclip-compression/png.rb', line 12 def make begin Paperclip.run(command_path('optipng'), "#{@cli_opts} :src_path", src_path: @src_path) if @cli_opts @file rescue Cocaine::ExitStatusError => e raise Paperclip::Error, "OPTIPNG : There was an error processing the thumbnail for #{@basename}" if @whiny rescue Cocaine::CommandNotFoundError => e raise Paperclip::Errors::CommandNotFoundError.new("Could not run 'optipng'. Please install optipng.") end end |