module

ImageProcessing::Chainable(P, Acc)

Implements a chainable interface for building processing options. P is the processor class, Acc its accumulator type. It is both included into Builder and extended into the ImageProcessing::Vips / MiniMagick modules, mirroring Ruby's extend Chainable.

Instance methods

apply(operations) : Builder(P, Acc)

Add multiple operations as a hash or an array.

.apply({resize_to_limit: [400, 400], strip: true})

or

.apply([{"resize_to_limit", [400, 400]}, {"strip", true}])

Source
branch(*, source : OptValue | Nil = nil, loader : Hash(String, OptValue) | Nil = nil, saver : Hash(String, OptValue) | Nil = nil, format : String | Nil = nil, format_given : Bool = false, operations : Array(Operation) | Nil = nil, destination : String | Nil = nil, instrumenter : Instrumenter | Nil = nil, instrumenter_given : Bool = false) : Builder(P, Acc)

Creates a new builder object, merging current options with new options.

Source
call(file = nil, *, destination : String | Nil = nil, **call_options)

Call the defined processing and get the result. Allows specifying the source file and destination.

Source
convert(format : String | Nil) : Builder(P, Acc)

Specify the output format.

Source
custom

Calls the given block with the accumulator object directly. Useful for when you want to access the accumulator object directly. Without a block the operation is a no-op returning the accumulator.

Source
custom
Source
instrumenter

Register instrumentation block that will be called around the pipeline. The block receives the pipeline options and a callable that runs the pipeline; its return value is ignored, like in the Ruby version.

Source
loader

Specify processor options applied when loading the image.

Source
operation(name : String, *args, **kwargs, &block : Proc(Acc, Acc | Nil)) : Builder(P, Acc)

Add an operation defined by the processor.

Source
operation(name : String, args : Array(OptValue), block : Block | Nil = nil) : Builder(P, Acc)

Runtime variant used by #apply and the generated bang methods, with already-normalized arguments.

Source
operation(name : String, *args, **kwargs) : Builder(P, Acc)
Source
saver

Specify processor options applied when saving the image.

Source
source(file) : Builder(P, Acc)

Specify the source image file.

Source
stack

Creates a stack in the accumulator (MiniMagick parentheses). Generic on Chainable so that the module-function form (MiniMagick.stack { }) works without method_missing, which Crystal cannot do for modules.

Source

Macros

method_missing(call)

Assume that any unknown method names an operation supported by the processor. Add a bang ("!") if you want processing to be performed.

Crystal's method_missing hook cannot generate defs that match calls with named arguments unless the named arguments are spelled out, so they are generated explicitly from the call site.

Source