Class: Retouch::Pipeline
- Inherits:
-
Object
show all
- Defined in:
- lib/retouch/pipeline.rb,
sig/retouch.rbs
Constant Summary
collapse
- OPERATIONS =
%i[
resize thumbnail crop flip flop rotate pad extend border trim
grayscale invert brightness contrast gamma saturate tint opacity quantize
blur sharpen pixelate overlay watermark text rect arrow
].freeze
Instance Method Summary
collapse
Constructor Details
#initialize(image, operations = []) ⇒ Pipeline
Returns a new instance of Pipeline.
11
12
13
14
15
16
|
# File 'lib/retouch/pipeline.rb', line 11
def initialize(image, operations = [])
raise TypeError, "image must be a Tessel::Image" unless image.is_a?(Tessel::Image)
@source = image.dup
@operations = operations.freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **options, &block) ⇒ Object
31
32
33
34
35
|
# File 'lib/retouch/pipeline.rb', line 31
def method_missing(name, *args, **options, &block)
return super if block || !OPERATIONS.include?(name)
self.class.new(@source, @operations + [[name, args, options]])
end
|
Instance Method Details
80
|
# File 'sig/retouch.rbs', line 80
def arrow: (Integer x1, Integer y1, Integer x2, Integer y2, ?String color, **untyped options) -> Pipeline
|
73
|
# File 'sig/retouch.rbs', line 73
def blur: (Numeric sigma) -> Pipeline
|
62
|
# File 'sig/retouch.rbs', line 62
def border: (Integer width, ?String color, **untyped options) -> Pipeline
|
66
|
# File 'sig/retouch.rbs', line 66
def brightness: (Numeric amount) -> Pipeline
|
67
|
# File 'sig/retouch.rbs', line 67
def contrast: (Numeric factor) -> Pipeline
|
56
|
# File 'sig/retouch.rbs', line 56
def crop: (String | Geometry geometry, **untyped options) -> Pipeline
|
61
|
# File 'sig/retouch.rbs', line 61
def extend: (Integer width, Integer height, **untyped options) -> Pipeline
|
57
|
# File 'sig/retouch.rbs', line 57
def flip: -> Pipeline
|
58
|
# File 'sig/retouch.rbs', line 58
def flop: -> Pipeline
|
68
|
# File 'sig/retouch.rbs', line 68
def gamma: (Numeric value) -> Pipeline
|
64
|
# File 'sig/retouch.rbs', line 64
def grayscale: -> Pipeline
|
#info ⇒ Hash[Symbol, untyped]
25
|
# File 'lib/retouch/pipeline.rb', line 25
def info = Operations.info(to_image)
|
65
|
# File 'sig/retouch.rbs', line 65
def invert: -> Pipeline
|
71
|
# File 'sig/retouch.rbs', line 71
def opacity: (Numeric amount) -> Pipeline
|
76
|
# File 'sig/retouch.rbs', line 76
def overlay: (String | untyped source, **untyped options) -> Pipeline
|
60
|
# File 'sig/retouch.rbs', line 60
def pad: (Integer amount, **untyped options) -> Pipeline
|
75
|
# File 'sig/retouch.rbs', line 75
def pixelate: (Integer size) -> Pipeline
|
72
|
# File 'sig/retouch.rbs', line 72
def quantize: (**untyped options) -> Pipeline
|
79
|
# File 'sig/retouch.rbs', line 79
def rect: (Integer x, Integer y, Integer width, Integer height, ?String color, **untyped options) -> Pipeline
|
54
|
# File 'sig/retouch.rbs', line 54
def resize: (String | Geometry geometry, **untyped options) -> Pipeline
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
37
38
39
|
# File 'lib/retouch/pipeline.rb', line 37
def respond_to_missing?(name, include_private = false)
OPERATIONS.include?(name) || super
end
|
59
|
# File 'sig/retouch.rbs', line 59
def rotate: (Numeric degrees, **untyped options) -> Pipeline
|
69
|
# File 'sig/retouch.rbs', line 69
def saturate: (Numeric factor) -> Pipeline
|
#save(path, **options) ⇒ String
27
28
29
|
# File 'lib/retouch/pipeline.rb', line 27
def save(path, **options)
ImageIO.write(to_image, String(path), **options)
end
|
74
|
# File 'sig/retouch.rbs', line 74
def sharpen: (Numeric sigma, **untyped options) -> Pipeline
|
78
|
# File 'sig/retouch.rbs', line 78
def text: (String text, **untyped options) -> Pipeline
|
55
|
# File 'sig/retouch.rbs', line 55
def thumbnail: (String | Geometry geometry, **untyped options) -> Pipeline
|
70
|
# File 'sig/retouch.rbs', line 70
def tint: (String color, **untyped options) -> Pipeline
|
#to_image ⇒ Object
18
19
20
21
22
23
|
# File 'lib/retouch/pipeline.rb', line 18
def to_image
@operations.reduce(@source.dup) do |image, (name, args, options)|
args = args.dup
Operations.apply(image, name, *args, **options)
end
end
|
63
|
# File 'sig/retouch.rbs', line 63
def trim: (**untyped options) -> Pipeline
|
77
|
# File 'sig/retouch.rbs', line 77
def watermark: (String | untyped source, **untyped options) -> Pipeline
|