Module: Imogen::Dzi
- Defined in:
- lib/imogen/dzi.rb
Class Method Summary collapse
- .convert(img, dest_dir, format = :jpeg, opts = {}) ⇒ Object
- .iiif_opts_for_dzi(level, max_levels, col, row, tile_size = 128, format = :jpeg) ⇒ Object
- .iiif_path_for_dzi(level, max_levels, col, row, tile_size = 512, format = :jpeg) ⇒ Object
- .iiif_paths(img, tile_size = 128, format = :jpeg) ⇒ Object
Class Method Details
.convert(img, dest_dir, format = :jpeg, opts = {}) ⇒ Object
5 6 7 8 |
# File 'lib/imogen/dzi.rb', line 5 def self.convert(img,dest_dir,format=:jpeg,opts={}) override = opts[:override] end |
.iiif_opts_for_dzi(level, max_levels, col, row, tile_size = 128, format = :jpeg) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/imogen/dzi.rb', line 31 def self.iiif_opts_for_dzi(level,max_levels,col,row,tile_size=128,format=:jpeg) level = level.to_i max_levels = max_levels.to_i c_ratio = 2**(max_levels-level) tile_side = tile_size*c_ratio x = col * c_ratio y = row * c_ratio { region: "#{x},#{y},#{tile_side},#{tile_side}", size: "!#{tile_size},#{tile_size}", format: format, rotation: 0, quality: :native } end |
.iiif_path_for_dzi(level, max_levels, col, row, tile_size = 512, format = :jpeg) ⇒ Object
47 48 49 50 |
# File 'lib/imogen/dzi.rb', line 47 def self.iiif_path_for_dzi(level,max_levels,col,row,tile_size=512,format=:jpeg) opts = iiif_opts_for_dzi(level, max_levels,col,row,tile_size,format) "#{opts[:region]}/#{opts[:size]}/#{opts[:rotation]}/#{opts[:quality]}.#{Imogen::Iiif::FORMATS[format]}" end |
.iiif_paths(img, tile_size = 128, format = :jpeg) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/imogen/dzi.rb', line 9 def self.iiif_paths(img,tile_size=128,format=:jpeg) width, height = img.width, img.height max_levels = Imogen::Zoomable.max_levels_for(width, height) results = {} max_levels.downto(0) do |level| c_ratio = 2**(max_levels-level) tile_side = tile_size*c_ratio x, col = 0, 0 while x < width y, row = 0, 0 while y < height results["#{level}/#{col_count}_#{row_count}"] = iiif_path_for_dzi(level,max_levels,col,row,tile_size,format) y += tile_side row += 1 end x += tile_side col += 1 end end end |