Class: Imogen::Iiif::Rotation
Constant Summary
collapse
- RIGHT_ANGLES =
[0,90,180,270]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Transform
#initialize, #max, #min
Class Method Details
.convert(img, rotate) {|img| ... } ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/imogen/iiif/rotation.rb', line 17
def self.convert(img, rotate)
angle, flip = Rotation.new(img).get(rotate)
img = img.fliphor if flip
img = img.rot("d#{angle}") unless angle.zero?
yield img
end
|
Instance Method Details
#get(rotate) ⇒ Object
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?('!')
angle = rotate.sub(/^!/, '').to_i % 360
raise BadRequest.new("bad rotate #{original_rotate_value}") unless RIGHT_ANGLES.include?(angle)
return angle, flip
end
|