Method: ActiveStorage::Transformers::Transformer#transform

Defined in:
activestorage/lib/active_storage/transformers/transformer.rb

#transform(file, format:) ⇒ Object

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.



23
24
25
26
27
28
29
30
31
# File 'activestorage/lib/active_storage/transformers/transformer.rb', line 23

def transform(file, format:)
  output = process(file, format: format)

  begin
    yield output
  ensure
    output.close!
  end
end