Module: Rszr::Image::Transformations
- Included in:
- Rszr::Image
- Defined in:
- lib/rszr/image.rb
Instance Method Summary collapse
- #blur(radius) ⇒ Object
- #blur!(radius) ⇒ Object
- #brighten(*args, **opts) ⇒ Object
- #brighten!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
- #contrast(*args, **opts) ⇒ Object
- #contrast!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
- #crop(x, y, width, height) ⇒ Object
- #crop!(x, y, width, height) ⇒ Object
- #filter(filter_expr) ⇒ Object
-
#flip ⇒ Object
vertical.
-
#flop ⇒ Object
horizontal.
- #gamma(*args, **opts) ⇒ Object
- #gamma!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
- #resize(*args, **opts) ⇒ Object
- #resize!(*args, **opts) ⇒ Object
- #rotate(deg) ⇒ Object
- #rotate!(deg) ⇒ Object
- #sharpen(radius) ⇒ Object
- #sharpen!(radius) ⇒ Object
- #turn(orientation) ⇒ Object
- #turn!(orientation) ⇒ Object
Instance Method Details
#blur(radius) ⇒ Object
108 109 110 |
# File 'lib/rszr/image.rb', line 108 def blur(radius) dup.blur!(radius) end |
#blur!(radius) ⇒ Object
112 113 114 115 |
# File 'lib/rszr/image.rb', line 112 def blur!(radius) raise ArgumentError, 'illegal radius' if radius < 0 _sharpen!(-radius) end |
#brighten(*args, **opts) ⇒ Object
126 127 128 |
# File 'lib/rszr/image.rb', line 126 def brighten(*args, **opts) dup.brighten!(*args, **opts) end |
#brighten!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
121 122 123 124 |
# File 'lib/rszr/image.rb', line 121 def brighten!(value, r: nil, g: nil, b: nil, a: nil) raise ArgumentError, 'illegal brightness' if value > 1 || value < -1 filter!("colormod(brightness=#{value.to_f});") end |
#contrast(*args, **opts) ⇒ Object
135 136 137 |
# File 'lib/rszr/image.rb', line 135 def contrast(*args, **opts) dup.contrast!(*args, **opts) end |
#contrast!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
130 131 132 133 |
# File 'lib/rszr/image.rb', line 130 def contrast!(value, r: nil, g: nil, b: nil, a: nil) raise ArgumentError, 'illegal contrast (must be > 0)' if value < 0 filter!("colormod(contrast=#{value.to_f});") end |
#crop(x, y, width, height) ⇒ Object
64 65 66 |
# File 'lib/rszr/image.rb', line 64 def crop(x, y, width, height) _crop(false, x, y, width, height) end |
#crop!(x, y, width, height) ⇒ Object
68 69 70 |
# File 'lib/rszr/image.rb', line 68 def crop!(x, y, width, height) _crop(true, x, y, width, height) end |
#filter(filter_expr) ⇒ Object
117 118 119 |
# File 'lib/rszr/image.rb', line 117 def filter(filter_expr) dup.filter!(filter_expr) end |
#flip ⇒ Object
vertical
95 96 97 |
# File 'lib/rszr/image.rb', line 95 def flip dup.flip! end |
#flop ⇒ Object
horizontal
90 91 92 |
# File 'lib/rszr/image.rb', line 90 def flop dup.flop! end |
#gamma(*args, **opts) ⇒ Object
144 145 146 |
# File 'lib/rszr/image.rb', line 144 def gamma(*args, **opts) dup.gamma!(*args, **opts) end |
#gamma!(value, r: nil, g: nil, b: nil, a: nil) ⇒ Object
139 140 141 142 |
# File 'lib/rszr/image.rb', line 139 def gamma!(value, r: nil, g: nil, b: nil, a: nil) #raise ArgumentError, 'illegal gamma (must be > 0)' if value < 0 filter!("colormod(gamma=#{value.to_f});") end |
#resize(*args, **opts) ⇒ Object
56 57 58 |
# File 'lib/rszr/image.rb', line 56 def resize(*args, **opts) _resize(false, *calculate_size(*args, **opts)) end |
#resize!(*args, **opts) ⇒ Object
60 61 62 |
# File 'lib/rszr/image.rb', line 60 def resize!(*args, **opts) _resize(true, *calculate_size(*args, **opts)) end |
#rotate(deg) ⇒ Object
81 82 83 |
# File 'lib/rszr/image.rb', line 81 def rotate(deg) _rotate(false, deg.to_f * Math::PI / 180.0) end |
#rotate!(deg) ⇒ Object
85 86 87 |
# File 'lib/rszr/image.rb', line 85 def rotate!(deg) _rotate(true, deg.to_f * Math::PI / 180.0) end |
#sharpen(radius) ⇒ Object
99 100 101 |
# File 'lib/rszr/image.rb', line 99 def sharpen(radius) dup.sharpen!(radius) end |
#sharpen!(radius) ⇒ Object
103 104 105 106 |
# File 'lib/rszr/image.rb', line 103 def sharpen!(radius) raise ArgumentError, 'illegal radius' if radius < 0 _sharpen!(radius) end |
#turn(orientation) ⇒ Object
72 73 74 |
# File 'lib/rszr/image.rb', line 72 def turn(orientation) dup.turn!(orientation) end |
#turn!(orientation) ⇒ Object
76 77 78 79 |
# File 'lib/rszr/image.rb', line 76 def turn!(orientation) orientation = orientation.abs + 2 if orientation.negative? _turn!(orientation % 4) end |