module Latch::Processor

Overview

Base module for processors that transform uploaded files into variants. Provides the variant and original macros with compile-time validation against a @[Latch::VariantOptions(...)] annotation declared by the concrete processor module.

Non-nilable annotation types are required in every variant call, nilable types are optional. Unknown keys cause a compile-time error.

See Latch::Processor::Magick for an ImageMagick-based implementation.

Direct including types

Defined in:

latch/processor.cr

Macro Summary

Macro Detail

macro original(**options) #

Defines processing options for the original file. The original is processed after all variants, so they use the maximum available quality.


[View source]
macro process(&block) #

Generates the boilerplate self.process on the concrete type. The block body is expanded inside the variant loop with stored_file, storage, name, tempfile, variant_name, and variant_options in scope.

Variants are processed first, then the original (if defined), so that variants always use the maximum available quality.


[View source]
macro variant(name, **options) #

Defines a named variant. Options are validated at compile time against the @[Latch::VariantOptions(...)] annotation on the processor.


[View source]