Sha256: 526e8f1e755798090dc38fcc8589506ca3614203cda867bf6f3336afe2b3f57a

Contents?: true

Size: 565 Bytes

Versions: 8

Compression:

Stored size: 565 Bytes

Contents

module Paperclip
  # Compresses the JPEG and PNG files
  class Compression < Processor

    def make
      case content_type
      when 'image/jpeg' then make_jpeg
      when 'image/png'  then make_png
      else
        @file
      end
    end

    private

    def make_jpeg
      PaperclipCompression::Jpeg.make(@file, @options)
    end

    def make_png
      PaperclipCompression::Png.make(@file, @options)
    end

    def content_type
      @file.is_a?(Paperclip::AbstractAdapter) ? @file.content_type : ImageSpec.new(@file).content_type
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
paperclip-compression-0.3.11 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.10 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.9 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.8 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.7 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.6 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.5 lib/paperclip-compression/paperclip/compression.rb
paperclip-compression-0.3.4 lib/paperclip-compression/paperclip/compression.rb