Class: Paperclip::Ghostscript
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::Ghostscript
- Defined in:
- lib/paperclip_processors/ghostscript.rb
Instance Attribute Summary collapse
-
#convert_options ⇒ Object
Returns the value of attribute convert_options.
-
#current_geometry ⇒ Object
Returns the value of attribute current_geometry.
-
#format ⇒ Object
Returns the value of attribute format.
-
#source_file_options ⇒ Object
Returns the value of attribute source_file_options.
-
#target_geometry ⇒ Object
Returns the value of attribute target_geometry.
-
#whiny ⇒ Object
Returns the value of attribute whiny.
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Ghostscript
constructor
A new instance of Ghostscript.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Ghostscript
Returns a new instance of Ghostscript.
11 12 13 14 15 16 17 18 |
# File 'lib/paperclip_processors/ghostscript.rb', line 11 def initialize file, = {}, = nil super @file = file @format = [:format] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) end |
Instance Attribute Details
#convert_options ⇒ Object
Returns the value of attribute convert_options.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def @convert_options end |
#current_geometry ⇒ Object
Returns the value of attribute current_geometry.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def current_geometry @current_geometry end |
#format ⇒ Object
Returns the value of attribute format.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def format @format end |
#source_file_options ⇒ Object
Returns the value of attribute source_file_options.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def @source_file_options end |
#target_geometry ⇒ Object
Returns the value of attribute target_geometry.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def target_geometry @target_geometry end |
#whiny ⇒ Object
Returns the value of attribute whiny.
9 10 11 |
# File 'lib/paperclip_processors/ghostscript.rb', line 9 def whiny @whiny end |
Instance Method Details
#make ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/paperclip_processors/ghostscript.rb', line 20 def make src = @file dst = Tempfile.new([@basename, @format ? ".#{@format}" : '']) dst.binmode begin if @current_format && @current_format.downcase == ".pdf" parameters = [] # parameters << "-dNOPAUSE -dBATCH -sDEVICE=jpeg -r144 -dUseCIEColor -dFirstPage=1 -dLastPage=1" # parameters << "-dFirstPage=1 -dLastPage=1" parameters << "-q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0" parameters << "-dGridFitTT=2 -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150" parameters << "-sOutputFile=:dest" parameters << ":source" parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ") Paperclip.run("gs", parameters, source: "#{File.(src.path)}", dest: File.(dst.path)) return dst else return src end rescue Cocaine::CommandNotFoundError => _ raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny end end |