Sha256: a2c5079ae9b349cbc81b1cca7c4d879c095b55a874228a0c257ce3b0c9c351df

Contents?: true

Size: 819 Bytes

Versions: 11

Compression:

Stored size: 819 Bytes

Contents

module PaperclipCompression
  class Png < Base

    OPTIPNG_DEFAULT_OPTS  = '-o 5'

    def initialize(file, options = {})
      super(file, options)
      @src_path = File.expand_path(@file.path)
      @cli_opts = init_cli_opts(:png, default_opts)
    end

    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

    private

    def default_opts
      OPTIPNG_DEFAULT_OPTS
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
paperclip-compression-0.3.10 lib/paperclip-compression/png.rb
paperclip-compression-0.3.9 lib/paperclip-compression/png.rb
paperclip-compression-0.3.8 lib/paperclip-compression/png.rb
paperclip-compression-0.3.7 lib/paperclip-compression/png.rb
paperclip-compression-0.3.6 lib/paperclip-compression/png.rb
paperclip-compression-0.3.5 lib/paperclip-compression/png.rb
paperclip-compression-0.3.4 lib/paperclip-compression/png.rb
paperclip-compression-0.3.3 lib/paperclip-compression/png.rb
paperclip-compression-0.3.2 lib/paperclip-compression/png.rb
paperclip-compression-0.3.1 lib/paperclip-compression/png.rb
paperclip-compression-0.3.0 lib/paperclip-compression/png.rb