Class: DragonflyLibvips::Processors::Rotate

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly_libvips/processors/rotate.rb

Instance Method Summary collapse

Instance Method Details

#call(content, rotate, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dragonfly_libvips/processors/rotate.rb', line 6

def call(content, rotate, options = {})
  options = options.deep_stringify_keys

  format = options.fetch('format', content.ext)

  input_options = options.fetch('input_options', {})
  output_options = options.fetch('output_options', {})

  input_options['access'] ||= 'sequential'
  output_options['profile'] ||= DragonflyLibvips::EPROFILE_PATH

  require 'vips'
  img = ::Vips::Image.new_from_file(content.path, input_options)

  img = img.rot("d#{rotate}")

  content.update(img.write_to_buffer(".#{format}", output_options), 'format' => format)
  content.ext = format
end

#update_url(url_attributes, _, options = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/dragonfly_libvips/processors/rotate.rb', line 26

def update_url(url_attributes, _, options = {})
  options = options.deep_stringify_keys

  if format = options.fetch('format', nil)
    url_attributes.ext = format
  end
end