imogen 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/imogen/iiif/region.rb +6 -6
- data/spec/unit/imogen_iiif_region_spec.rb +8 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZmQ3M2I5NDc5ZDg5MjNiNGUyYTAxZDNmNDFiZjg5NmI0ZmExMzYzNg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 72d6fdb5d3ff30a5b88603de22b081704f0cd525
|
4
|
+
data.tar.gz: f4bbe60079ba2216d8e7f58f50a355e3a553f45c
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NjkwN2E3NmFiNTNlZjRlYzUwOWYzYTk5MDIwNTFhZTZiZDgxMjIzNmFkNGJl
|
11
|
-
YmRkMWUzMWQwM2YyZDUwMjFjOTE3ZGY5NzE0NzNkMDJiYTMzZTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODRkMDgwMmRkMmE2YjY1ZGU5NWRlNmMxZDJhNmM5NTU2ZTQ0YWQwNDU5MzVl
|
14
|
-
YWIxZDNiM2NlYjQ5ZjBlYTUwZDRiZWE2NGU2YWJhNWYxZWY4NTQxMGVkMjcx
|
15
|
-
NWI0ODZiNjQ2NmMzMzZhOGEwOTY5ZTY3MDk2NWVkZGIzMzJiNDM=
|
6
|
+
metadata.gz: 19e7f16d7f1e6cc363baf6000988c81de25429420fdd7d8282f8796a9d6e99304796ad50835ad7d63fcfad012c6bce3ac47f502db535da32e7b63bdab2b1939d
|
7
|
+
data.tar.gz: f3c05ae821d2a6ab630c3bfe5753473a5c3070949bc0c1bf202f75aa368111642b84e87c0c5e7ad05d28c4c04d274d18bbe37e4ac0900535ea8aa7b9a0b25693
|
data/lib/imogen/iiif/region.rb
CHANGED
@@ -11,7 +11,7 @@ class Region < Transform
|
|
11
11
|
return :featured
|
12
12
|
elsif md = /^pct:(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?)$/.match(region)
|
13
13
|
p = [Float(md[1]),Float(md[3]),Float(md[5]),Float(md[7])]
|
14
|
-
if p[
|
14
|
+
if p[2] == 0 or p[3] == 0
|
15
15
|
raise BadRequest.new("Invalid region: #{region}")
|
16
16
|
end
|
17
17
|
e = [
|
@@ -32,12 +32,12 @@ class Region < Transform
|
|
32
32
|
min(@height,(p[1] + p[3]))
|
33
33
|
]
|
34
34
|
else
|
35
|
-
raise BadRequest.new("Invalid region: #{region}")
|
36
|
-
end
|
37
|
-
if e[0] > e[2] or e[1] > e[3]
|
38
|
-
raise BadRequest.new("Invalid region: #{region}")
|
35
|
+
raise BadRequest.new("Invalid region (syntax): #{region}")
|
39
36
|
end
|
40
|
-
if (e[
|
37
|
+
if (e[0] > @width or e[1] > @height)
|
38
|
+
raise BadRequest.new("Invalid region (disjoint): #{region}")
|
39
|
+
end
|
40
|
+
if (e[2]) * (e[3]) < 100
|
41
41
|
raise BadRequest.new("Region too small: #{region}")
|
42
42
|
end
|
43
43
|
return e
|
@@ -37,7 +37,7 @@ describe Imogen::Iiif::Region, type: :unit do
|
|
37
37
|
expect(subject.get("pct:80,15,10,75")).to eql([140,20,158,118])
|
38
38
|
end
|
39
39
|
it "should reject zero-dimension boxes" do
|
40
|
-
expect{subject.get("pct:10.2,15,
|
40
|
+
expect{subject.get("pct:10.2,15,0,15")}.to raise_error Imogen::Iiif::BadRequest
|
41
41
|
end
|
42
42
|
describe "that exceeds the bounds" do
|
43
43
|
it "should calculate an overlapping region" do
|
@@ -52,6 +52,12 @@ describe Imogen::Iiif::Region, type: :unit do
|
|
52
52
|
expect{subject.get("px:1,2,3,4")}.to raise_error Imogen::Iiif::BadRequest
|
53
53
|
expect{subject.get("-1,2,3,4")}.to raise_error Imogen::Iiif::BadRequest
|
54
54
|
expect{subject.get("pct:-1,2,3,4")}.to raise_error Imogen::Iiif::BadRequest
|
55
|
-
end
|
55
|
+
end
|
56
|
+
it "should work for some other image" do
|
57
|
+
img = ImageStub.new(1706,1726)
|
58
|
+
test = Imogen::Iiif::Region.new(img)
|
59
|
+
expect(test.get("1536,1024,190,512")).to eql([1536,1024,1706,1536])
|
60
|
+
expect{subject.get("1536,1024,190,512")}.to raise_error Imogen::Iiif::BadRequest
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imogen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Armintor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-opencv
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description:
|
@@ -70,12 +70,12 @@ require_paths:
|
|
70
70
|
- lib
|
71
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|