Method: Imogen::Iiif::Rotation#get

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

#get(rotate) ⇒ Object

Raises:



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/imogen/iiif/rotation.rb', line 5

def get(rotate)
  return [0, false] if rotate.nil?
  original_rotate_value = rotate
  rotate = rotate.to_s
  raise BadRequest.new("bad rotate #{original_rotate_value}") unless rotate =~ /^!?-?\d+$/
  flip = rotate.to_s.start_with?('!')
  # libvips and IIIF spec counts clockwise
  angle = rotate.sub(/^!/, '').to_i % 360
  raise BadRequest.new("bad rotate #{original_rotate_value}") unless RIGHT_ANGLES.include?(angle)
  return angle, flip
end