class ActiveStorage::VariantProcessor::VipsProcessor

Overview

Runs the transformations of a variation with libvips.

This is the processor Rails defaults to from load_defaults 7.0 on (config.active_storage.variant_processor = :vips), and every operation below mirrors image_processing's vips backend, so a variant produced here carries the dimensions Rails' own pass would have produced. Byte equality is not a goal: it moves with the libvips version.

The source is loaded once and each operation is applied in the order the variation wrote it, which is why #process walks the hash instead of looking up known keys: rotate before a resize and rotate after it are different images. https://github.com/janko/image_processing/blob/master/lib/image_processing/vips.rb

Direct Known Subclasses

Defined in:

active_storage/variant_processor/vips_processor.cr

Constant Summary

MAX_COORD = 10000000

Stands for a dimension that is not constrained.

The resize operations take a box, and a nil side means "leave this one free". libvips has no such value, so image_processing passes Vips::MAX_COORD instead, which is this number.

Instance Method Summary

Instance methods inherited from class ActiveStorage::VariantProcessor

process(source : Bytes, transformations : JSON::Any, format : String) : Bytes process

Instance Method Detail

def process(source : Bytes, transformations : JSON::Any, format : String) : Bytes #
Description copied from class ActiveStorage::VariantProcessor

Returns source with transformations applied, encoded as format.

transformations carries no format key, matching the transformations.except(:format) that Rails hands its transformer.

Raises NotImplementedError unless a backend is assigned, as the Rails base service does for the methods a service has to implement.