Class: ActiveStorage::HotCell::Server::Analyzers::Image::Vips

Inherits:
VipsOperation show all
Defined in:
lib/active_storage/hot_cell/server/analyzers/image/vips.rb

Overview

Metadata and no bytes, which is the request shape with no outputs at all.

Shipping this is mandatory rather than a nicety. The built-in image analyzers gate accept? on variant_processor being :vips or :mini_magick, so a class value makes them all decline, analyzer_class falls through to NullAnalyzer, and the blob is marked analyzed with no dimensions at all.

There is a sharper version of the same problem inside the built-in vips analyzer, which this deliberately does not copy: it rescues every Vips::Error and returns an empty hash, which is then merged with analyzed: true. An undecodable image is recorded as successfully analyzed, forever, and nothing re-enqueues AnalyzeJob. Here an undecodable input raises Vips::Error, the cell answers unreadable, and the client decides — because only the client knows whether that verdict is safe to write down.

Constant Summary

Constants inherited from Operation

Operation::CONTENT_TYPES

Instance Method Summary collapse

Instance Method Details

#perform(inputs, _outputs) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/active_storage/hot_cell/server/analyzers/image/vips.rb', line 30

def perform(inputs, _outputs)
  source, = inputs
  image = ::Vips::Image.new_from_file(source.fd_path, access: :sequential)

  { **dimensions_of(image), **frames_of(image),
    bytes: source.to_io.stat.size, tracked_mem_highwater: vips_highwater }
end