imogen 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/imogen/iiif/size.rb +10 -1
- data/spec/unit/imogen_iiif_size_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTc3NzAyOGZkYmNhYWIzYjNmM2VhNGQ1NzQ5M2E5M2I4ZTNiNWQ2OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjJkMDQ4YTU1NmJlNTllMWZkNWI4ZDMwZjZkNmY4OGE1MDU2YzA0Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzZmODU5YzA2ODA5YmMyNzFkMTRkNWM2NjBlZmQ5NGY1OGFlMTZmMzEyZjU1
|
10
|
+
YTljZjY0M2EyNjJkYWI5ODYxYmMzY2FlNmNiZTBkY2JiYTYwOTNkNDQyNmM5
|
11
|
+
ZWVhOWM1YWE3ZTczYjc2YmFjZjlmZGVhMmZmMDViMDE1NDUzZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTNkMTJiZmI0NGE4ZWY1YmYwOWI5OGEzYzQzODcyYmI1YjQ5ZDdiMGM2MTlk
|
14
|
+
MWM2YWE4YTRiOTc4ZmIxMzY3YzIyNzYxZDQ1NGI5YTE1YWFmZGJhOWU4MDVi
|
15
|
+
YmIwNzFkZDQ2ZGU3MDc1ZDE0YjRlOGY3YzU4OTRjZjhkOWEwZTY=
|
data/lib/imogen/iiif/size.rb
CHANGED
@@ -5,7 +5,7 @@ class Size < Transform
|
|
5
5
|
if scale.nil? or scale.eql? "full"
|
6
6
|
return nil
|
7
7
|
end
|
8
|
-
if md = /^(\d+)?,(\d+)?$/.match(scale)
|
8
|
+
if md = /^[!]?(\d+)?,(\d+)?$/.match(scale)
|
9
9
|
w = md[1] ? min(Integer(md[1]), @width) : nil
|
10
10
|
h = md[2] ? min(Integer(md[2]), @height) : nil
|
11
11
|
raise BadRequest.new("bad scale #{scale}") unless w or h
|
@@ -21,6 +21,15 @@ class Size < Transform
|
|
21
21
|
raise BadRequest.new("bad size #{scale}")
|
22
22
|
end
|
23
23
|
raise BadRequest.new("bad size #{scale}") if e[0] <= 0 or e[1] <= 0
|
24
|
+
if scale.start_with? '!'
|
25
|
+
w_ratio = e[0].to_f / @width
|
26
|
+
h_ratio = e[1].to_f / @height
|
27
|
+
if w_ratio > h_ratio
|
28
|
+
e[0] = (@width * h_ratio).round
|
29
|
+
elsif h_ratio > w_ratio
|
30
|
+
e[1] = (@height * w_ratio).round
|
31
|
+
end
|
32
|
+
end
|
24
33
|
return e
|
25
34
|
end
|
26
35
|
def self.convert(img, size)
|
@@ -34,6 +34,7 @@ describe Imogen::Iiif::Size, type: :unit do
|
|
34
34
|
describe "with scaling width and height" do
|
35
35
|
it "should calculate for a good value" do
|
36
36
|
expect(subject.get("105,79")).to eql([105, 79])
|
37
|
+
expect(subject.get("105,105")).to eql([105, 105])
|
37
38
|
end
|
38
39
|
it "should not upscale" do
|
39
40
|
expect(subject.get("350,262")).to eql([175, 131])
|
@@ -44,6 +45,9 @@ describe Imogen::Iiif::Size, type: :unit do
|
|
44
45
|
expect{subject.get("0,262")}.to raise_error Imogen::Iiif::BadRequest
|
45
46
|
expect{subject.get("0,262")}.to raise_error Imogen::Iiif::BadRequest
|
46
47
|
end
|
48
|
+
it "should caculate for 'contained' Wh" do
|
49
|
+
expect(subject.get("!105,105")).to eql([105, 79])
|
50
|
+
end
|
47
51
|
end
|
48
52
|
describe "with a percentage scale" do
|
49
53
|
it "should calculate for a good value" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-opencv
|