A Transformer applies a set of transformations to an image.
The following concrete subclasses are included in Active Storage:
ActiveStorage::Transformers::ImageProcessingTransformer: backed by ImageProcessing, a common interface for MiniMagick and ruby-vips
ActiveStorage::Transformers::MiniMagickTransformer: backed by MiniMagick, a wrapper around the ImageMagick CLI
# File activestorage/lib/active_storage/transformers/transformer.rb, line 24 def transform(file, format:) output = process(file, format: format) begin yield output ensure output.close! end end
Applies the transformations to the source image in file
, producing a target image in the specified format
. Yields an open Tempfile containing the target image. Closes and unlinks the output tempfile after yielding to the given block. Returns the result of the block.
© 2004–2019 David Heinemeier Hansson
Licensed under the MIT License.