Sha256: 941951ea7c129fa1a8c27dab20f96066ced41cfad0002f73e7b55b48056d999b
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module Riiif module Region # Represents requested square cooridnates class Square < Crop def initialize(image_info) @image_info = image_info @min, @max = [@image_info.width, @image_info.height].minmax @offset = (@max - @min) / 2 end # @return [String] a square region for imagemagick to decode # (appropriate for passing to the -crop parameter) def to_imagemagick if @image_info.height >= @image_info.width "#{height}x#{width}+0+#{@offset}" else "#{height}x#{width}+#{@offset}+0" end end # @return [String] a region for kakadu to decode # (appropriate for passing to the -region parameter) def to_kakadu # (top, left, height, width) if @image_info.height >= @image_info.width # Portrait "\{#{decimal_height(@offset)},0\}," \ "\{#{decimal_height(height)},#{decimal_width(height)}\}" else # Landscape "\{0,#{decimal_width(@offset)}\}," \ "\{#{decimal_height(width)},#{decimal_width(width)}\}" end end def height @min end def width @min end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riiif-2.0.0.beta2 | app/services/riiif/region/square.rb |
riiif-2.0.0.beta1 | app/services/riiif/region/square.rb |