Sha256: 06c6bb60f69557906a196dbe5b54bdbbe07872c5b0296e89ac27117c095763cd
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module PaperclipCompression class Jpeg < Base JPEGTRAN_DEFAULT_OPTS = '-copy none -optimize -perfect' def initialize(file, options = {}) super(file, options) @dst = Tempfile.new(@basename) @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 # close dst file, so jpegtran can write it @dst.close Paperclip.run(command_path('jpegtran'), "#{@cli_opts} :src_path > :dst_path", src_path: @src_path, dst_path: @dst_path) @dst.open @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
3 entries across 3 versions & 1 rubygems