riiif 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/riiif/image.rb +11 -0
- data/lib/riiif/version.rb +1 -1
- data/spec/models/riiif/image_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f471dbabbb6d626cbc8477de2490b0ed732b8e
|
4
|
+
data.tar.gz: de3732ff0b0d71d96474e650fc1e72df8564e772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b704b4e3a0c8fbda79a78b040f1d6dec12db688932ccdbfdaa8ce7b74419aa1a152930d6e2e7eeec2dfbaa51d52b77853651381a4709cb4f50164428f60f5092
|
7
|
+
data.tar.gz: 711c3a7639ac468462b88fbabe5840f0a6fe6c2bedd51a300bbd19404ff8dffca8a29d585a365a59cbe41db9fd4c453b4a91e84cf531a74172acab6fa11238c2
|
data/app/models/riiif/image.rb
CHANGED
@@ -99,6 +99,17 @@ module Riiif
|
|
99
99
|
"#{md[3]}%x#{md[4]}+#{offset_x}+#{offset_y}"
|
100
100
|
elsif md = /^(\d+),(\d+),(\d+),(\d+)$/.match(region)
|
101
101
|
"#{md[3]}x#{md[4]}+#{md[1]}+#{md[2]}"
|
102
|
+
elsif region == 'square'
|
103
|
+
w = info[:width]
|
104
|
+
h = info[:height]
|
105
|
+
min, max = [w, h].minmax
|
106
|
+
|
107
|
+
offset = (max - min) / 2
|
108
|
+
if h >= w
|
109
|
+
"#{min}x#{min}+0+#{offset}"
|
110
|
+
else
|
111
|
+
"#{min}x#{min}+#{offset}+0"
|
112
|
+
end
|
102
113
|
else
|
103
114
|
raise InvalidAttributeError, "Invalid region: #{region}"
|
104
115
|
end
|
data/lib/riiif/version.rb
CHANGED
@@ -75,6 +75,11 @@ describe Riiif::Image do
|
|
75
75
|
expect(subject.image).to receive(:execute).with("convert -crop 80%x70+18+13 #{filename} png:-")
|
76
76
|
subject.render(region: 'pct:10,10,80,70', format: 'png')
|
77
77
|
end
|
78
|
+
it 'handles square geometry' do
|
79
|
+
expect(subject.image).to receive(:execute).with("identify -format %hx%w #{filename}").and_return('131x175')
|
80
|
+
expect(subject.image).to receive(:execute).with("convert -crop 131x131+22+0 #{filename} png:-")
|
81
|
+
subject.render(region: 'square', format: 'png')
|
82
|
+
end
|
78
83
|
it 'raises an error for invalid geometry' do
|
79
84
|
expect { subject.render(region: '150x75', format: 'png') }.to raise_error Riiif::InvalidAttributeError
|
80
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riiif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|