Module: ActiveStorage::HotCell::Server::Transforming

Included in:
ActiveStorage::HotCell::Server::Transformers::Image::Magick, ActiveStorage::HotCell::Server::Transformers::Image::Vips
Defined in:
lib/active_storage/hot_cell/server/transforming.rb

Overview

The transform shared by the two toolchains. An includer names its ImageProcessing backend with processor, how the source reaches it with source_path, and what it reports with describe.

Instance Method Summary collapse

Instance Method Details

#perform(inputs, outputs, format:, operations: {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_storage/hot_cell/server/transforming.rb', line 11

def perform(inputs, outputs, format:, operations: {})
  source, = inputs
  destination, = outputs

  format = format.to_s

  # ImageProcessing chooses its saver from the destination's extension, and a scratch path has none,
  # so encode to a suffixed sibling on the slot's own scratch and adopt it into place. That is one
  # rename rather than the copy-out-of-Dir.tmpdir that a destination-less `call` would do, and it
  # keeps ImageProcessing's own saver — quality, strip, format defaults — rather than reaching past
  # it to the library, which cannot reproduce those without restating them. Output#post makes the
  # one remaining copy, out through the caller's descriptor.
  encoded = destination.path(extension: format)
  pipeline(source_path(source), format, operations).call(destination: encoded)
  destination.adopt encoded

  describe destination.path, format
end