Module: Imogen

Extended by:
FFI::Library
Defined in:
lib/imogen.rb,
lib/imogen/dzi.rb,
lib/imogen/iiif.rb,
lib/imogen/zoomable.rb,
lib/imogen/auto_crop.rb,
lib/imogen/iiif/size.rb,
lib/imogen/iiif/tiles.rb,
lib/imogen/iiif/region.rb,
lib/imogen/iiif/rotation.rb

Defined Under Namespace

Modules: AutoCrop, Cropped, Dzi, Iiif, Scaled, Zoomable

Class Method Summary collapse

Class Method Details

.clear_vips_cache_memObject

TODO: The clear_vips_cache_mem method can be removed once these two tickets are addressed: 1) github.com/libvips/ruby-vips/issues/360 2) github.com/libvips/libvips/pull/3370



61
62
63
64
65
66
67
68
69
70
# File 'lib/imogen.rb', line 61

def self.clear_vips_cache_mem
  # store original max because we'll restore it later
  original_max_value = vips_cache_get_max_mem

  # Drop max mem to 0, which also internally triggers a trim operation that clears out old cache entries
  vips_cache_set_max_mem(0)

  # Restore original value to support future caching operations
  vips_cache_set_max_mem(original_max_value)
end

.format_from(image_path) ⇒ Object



35
36
37
# File 'lib/imogen.rb', line 35

def self.format_from(image_path)
  raise "format from path not implemented"
end

.from(src_path) {|Vips::Image.matload(src_path)| ... } ⇒ Object

Yields:

  • (Vips::Image.matload(src_path))


15
16
17
# File 'lib/imogen.rb', line 15

def self.from(src_path)
  yield Vips::Image.matload(src_path)
end

.image(src_path, opts = {}) ⇒ Object

Parameters:

  • src_path (String)

    The local file path to the image.

  • opts (Hash) (defaults to: {})

    The options to use when opening an image.

Options Hash (opts):

  • :nocache (Boolean)

    When true, will clear the Vips cache before opening the image.



42
43
44
45
46
47
48
49
# File 'lib/imogen.rb', line 42

def self.image(src_path, opts = {})
  # TODO: Change to `new_from_file(src_path, {nocache: nocache})`, or something similar,
  # when these two GitHub issues are addressed:
  # 1) https://github.com/libvips/ruby-vips/issues/360
  # 2) https://github.com/libvips/libvips/pull/3370
  clear_vips_cache_mem if opts[:nocache] == true
  Vips::Image.new_from_file(src_path)
end

.with_image(src_path, opts = {}, &block) ⇒ Object

Parameters:

  • src_path (String)

    The local file path to the image.

  • opts (Hash) (defaults to: {})

    The options to use when opening an image.

Options Hash (opts):

  • :nocache (Boolean)

    When true, will clear the Vips cache before opening the image.



54
55
56
# File 'lib/imogen.rb', line 54

def self.with_image(src_path, opts = {}, &block)
  block.yield(image(src_path, opts))
end