Class: Paperclip::Grayscale
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::Grayscale
- Defined in:
- lib/grayscale_paperclip_processor/grayscale.rb
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Grayscale
constructor
A new instance of Grayscale.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Grayscale
Returns a new instance of Grayscale.
4 5 6 7 8 9 10 |
# File 'lib/grayscale_paperclip_processor/grayscale.rb', line 4 def initialize file, = {}, = nil super @file = file @geometry = [:geometry] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) end |
Instance Method Details
#make ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/grayscale_paperclip_processor/grayscale.rb', line 12 def make dst = Tempfile.new(@basename) dst.binmode command = "#{File.(@file.path)} -resize #{@geometry} -colorspace Gray #{File.(dst.path)}" begin success = Paperclip.run("convert", command) rescue PaperclipCommandLineError raise PaperclipError, "There was an error converting the image to grayscale for #{@basename}" end dst end |