Class: PaperclipCompression::Png

Inherits:
Base
  • Object
show all
Defined in:
lib/paperclip-compression/png.rb

Constant Summary collapse

KEY =
:png
OPTIPNG_DEFAULT_OPTS =
'-o 5 -quiet'

Instance Method Summary collapse

Methods inherited from Base

make, #process_file

Constructor Details

#initialize(file, first_processor, options = {}) ⇒ Png

Returns a new instance of Png.



7
8
9
10
# File 'lib/paperclip-compression/png.rb', line 7

def initialize(file, first_processor, options = {})
  super(file, first_processor)
  @config = PaperclipCompression::Config.create_with_fallbacks(options, KEY, gem_defaults)
end

Instance Method Details

#makeObject



12
13
14
15
16
17
18
19
20
# File 'lib/paperclip-compression/png.rb', line 12

def make
  begin
    @config.process_file? ? process_file : unprocessed_tempfile
  rescue Cocaine::ExitStatusError => e
    raise Paperclip::Error, "OPTIPNG : There was an error processing #{@basename}" if @config.whiny
  rescue Cocaine::CommandNotFoundError => e
    raise Paperclip::Errors::CommandNotFoundError.new("Could not run 'optipng'. Please install optipng.")
  end
end