Class: PaperclipCompression::Jpeg

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

Constant Summary collapse

KEY =
:jpeg
JPEGTRAN_DEFAULT_OPTS =
'-copy none -optimize -perfect'

Instance Method Summary collapse

Methods inherited from Base

make, #process_file

Constructor Details

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

Returns a new instance of Jpeg.



7
8
9
10
# File 'lib/paperclip-compression/jpeg.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/jpeg.rb', line 12

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