Method: Imogen::Iiif::Tiles.generate_with_vips_dzsave

Defined in:
lib/imogen/iiif/tiles.rb

.generate_with_vips_dzsave(img, output_dir, format: :jpeg, tile_size: 128, tile_filename_without_extension: 'default') ⇒ Object

This method should NOT be used right now because it’s missing some tiles that we rely on. This method is just here as a partial vips-dzsave-based implementation that we may want to build off in a fututure release. The Imogen::Iiif::Tiles.for method should be used instead, since it generates all of the expected tiles. The issue with this method may be related to this: github.com/libvips/libvips/discussions/2036



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/imogen/iiif/tiles.rb', line 135

def self.generate_with_vips_dzsave(img, output_dir, format: :jpeg, tile_size: 128, tile_filename_without_extension: 'default')
  warn "Warning: The generate_with_vips_dzsave is only partially functional and should not "\
       "be used to generate tiles yet.  If you use this method, some IIIF tiles will be missing."
  format = :jpg if format == :jpeg
  format = format.to_sym
  img.dzsave(
    output_dir,
    layout: 'iiif',
    suffix: ".tmp.#{format}",
    overlap: 0,
    tile_size: tile_size
  )

  # Update tile names with desired value
  Dir[File.join(output_dir, "**/*.tmp.#{format}")].each do |file_path|
    new_name = File.join(File.dirname(file_path), "#{tile_filename_without_extension}.#{format}")
    File.rename(file_path, new_name)
  end

  # Clean up unused additional dzsave files
  ['info.json', 'vips-properties.xml'].each do |unnecessary_file_name|
    File.delete(file_to_delete)
  end
end