Module: CarrierWave::Processing::RMagick

Defined in:
lib/carrierwave-processing/rmagick.rb

Instance Method Summary collapse

Instance Method Details

#blur(radius, sigma) ⇒ Object

reduce image noise and reduce detail levels

process :blur => [0, 8]

51
52
53
54
55
56
57
# File 'lib/carrierwave-processing/rmagick.rb', line 51

def blur(radius, sigma)
  manipulate! do |img|
    img = img.blur_image(radius, sigma)
    img = yield(img) if block_given?
    img
  end
end

#colorspace(cs) ⇒ Object

Sets the colorspace of the image to the specified value.

process :colorspace => :rgb # force rgb
process :colorspace => :cmyk # force cmyk

33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/carrierwave-processing/rmagick.rb', line 33

def colorspace(cs)
  manipulate! do |img|
    case cs.to_sym
    when :rgb
      img.colorspace = Magick::RGBColorspace
    when :cmyk
      img.colorspace = Magick::CMYKColorspace
    end
    img = yield(img) if block_given?
    img
  end
end

#quality(percentage) ⇒ Object

Reduces the quality of the image to the percentage given

process :quality => 90

20
21
22
23
24
25
26
# File 'lib/carrierwave-processing/rmagick.rb', line 20

def quality(percentage)
  manipulate! do |img|
    img.write(current_path){ self.quality = percentage }
    img = yield(img) if block_given?
    img
  end
end

#stripObject

Strips out all embedded information from the image

process :strip

8
9
10
11
12
13
14
# File 'lib/carrierwave-processing/rmagick.rb', line 8

def strip
  manipulate! do |img|
    img.strip!
    img = yield(img) if block_given?
    img
  end
end