Sha256: 8fed0c52b8aadd70463e1ca060fc2617f0964ff29033b9685256547e04911634
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module PaperclipCompression class Jpeg < Base JPEGTRAN_DEFAULT_OPTS = '-copy none -optimize -perfect' def initialize(file, options = {}) super(file, options) format = options[:format] @dst = Tempfile.new([@basename, format ? ".#{format}" : '']) @dst.binmode @src_path = File.expand_path(@file.path) @dst_path = File.expand_path(@dst.path) @cli_opts = init_cli_opts(:jpeg, default_opts) end def make begin if @cli_opts Paperclip.run(command_path('jpegtran'), "#{@cli_opts} :src_path > :dst_path", src_path: @src_path, dst_path: @dst_path) @dst else @file end rescue Cocaine::ExitStatusError => e raise Paperclip::Error, "JPEGTRAN : There was an error processing the thumbnail for #{@basename}" if @whiny rescue Cocaine::CommandNotFoundError => e raise Paperclip::Errors::CommandNotFoundError.new("Could not run 'jpegtran'. Please install jpegtran.") end end private def default_opts JPEGTRAN_DEFAULT_OPTS end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paperclip-compression-0.3.1 | lib/paperclip-compression/jpeg.rb |
paperclip-compression-0.3.0 | lib/paperclip-compression/jpeg.rb |