imogen 0.1.1 → 0.1.2
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.rb +2 -2
- data/lib/imogen/iiif/region.rb +14 -4
- data/spec/unit/imogen_iiif_quality_spec.rb +20 -0
- data/spec/unit/imogen_iiif_region_spec.rb +5 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmIyN2FkZGFmNTc2MTdhMDljZDMxOWRjMDgxMmFkOGVhZDBkYmVhNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODIyZmQ0NWM5ZGRjY2Y2MDY4NzY3NmQ4ZDEwMDVlNDM3OGQxNTY4Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmVhYjFmYmUwNmJkMGZhZjM3MjU4ZTkyNDNhOWI5N2U1ZGI5ZDA3ZTJhNTFm
|
10
|
+
MjZlYWU4YjI3MjdlNjRlYjIyZmM3YzhlYTk4M2RkMDYyY2NlYTVkMmQyOTAz
|
11
|
+
NzA5YzQwZjgwMTFmOWFlM2MwNDRiZWJjMzQwNTgxMjk5YzI2MjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjRmNzUwZGZmM2RmOGI1ZmExNWIwZTk4MmNlNTE4YjNiN2UwZWZkYzBhNDc4
|
14
|
+
N2EwNmQyYTg1MDNlNDE1M2YyNzRjZjBlOTY4ZDA1MjUwMDljNjJmYzVmNTEw
|
15
|
+
MDhmYmU2ODM0OGIwYzRhNjliMzQ2YjVjNjQ5NjUyNGUxYzMzYjY=
|
data/lib/imogen/iiif.rb
CHANGED
@@ -21,11 +21,11 @@ module Imogen
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
module Quality
|
24
|
-
VALUES =
|
24
|
+
VALUES = {native: nil, default: nil, color: nil, bitonal: :bitonal, grey: :grey, gray: :grey}
|
25
25
|
def self.get(quality=:native)
|
26
26
|
q = (quality || :native).to_sym
|
27
27
|
raise BadRequest.new("bad quality #{quality}") unless VALUES.include? q
|
28
|
-
return
|
28
|
+
return VALUES[q]
|
29
29
|
end
|
30
30
|
def self.convert(img, quality)
|
31
31
|
q = get(quality)
|
data/lib/imogen/iiif/region.rb
CHANGED
@@ -5,8 +5,10 @@ module Iiif
|
|
5
5
|
class Region < Transform
|
6
6
|
# returns leftX, topY, rightX, bottomY
|
7
7
|
def get(region=nil)
|
8
|
-
if region.nil? || region == 'full'
|
8
|
+
if region.nil? || region.to_s == 'full'
|
9
9
|
return nil
|
10
|
+
elsif region.to_s == 'featured'
|
11
|
+
return :featured
|
10
12
|
elsif md = /^pct:(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?)$/.match(region)
|
11
13
|
p = [Float(md[1]),Float(md[3]),Float(md[5]),Float(md[7])]
|
12
14
|
if p[0] == p[2] or p[1] == p[3]
|
@@ -42,10 +44,18 @@ class Region < Transform
|
|
42
44
|
end
|
43
45
|
def self.convert(img, region)
|
44
46
|
edges = Region.new(img).get(region)
|
45
|
-
if edges
|
46
|
-
img.copy(*edges) {|crop| yield crop}
|
47
|
-
else
|
47
|
+
if edges.nil?
|
48
48
|
yield img
|
49
|
+
else
|
50
|
+
if edges == :featured
|
51
|
+
frame = Imogen::AutoCrop::Edges.new(img)
|
52
|
+
begin
|
53
|
+
edges = frame.get([img.width, img.height,768].min)
|
54
|
+
ensure
|
55
|
+
frame.unlink
|
56
|
+
end
|
57
|
+
end
|
58
|
+
img.copy(*edges) {|crop| yield crop}
|
49
59
|
end
|
50
60
|
end
|
51
61
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'imogen/iiif'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
describe Imogen::Iiif::Quality, type: :unit do
|
4
|
+
before(:all) do
|
5
|
+
@test_image = ImageStub.new(175,131)
|
6
|
+
end
|
7
|
+
describe "#get" do
|
8
|
+
it "should nil for all the supported no-op values" do
|
9
|
+
expect(subject.get('native')).to be_nil
|
10
|
+
expect(subject.get('color')).to be_nil
|
11
|
+
expect(subject.get('default')).to be_nil
|
12
|
+
expect(subject.get(nil)).to be_nil
|
13
|
+
end
|
14
|
+
it "should return appropriate symbols for the transform values" do
|
15
|
+
expect(subject.get('grey')).to eql(:grey)
|
16
|
+
expect(subject.get('gray')).to eql(:grey)
|
17
|
+
expect(subject.get('bitonal')).to eql(:bitonal)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,11 +6,14 @@ describe Imogen::Iiif::Region, type: :unit do
|
|
6
6
|
end
|
7
7
|
subject {Imogen::Iiif::Region.new(@test_image)}
|
8
8
|
describe "#get" do
|
9
|
-
describe "with
|
10
|
-
it "should return nil" do
|
9
|
+
describe "with named regions" do
|
10
|
+
it "should return nil for full or default" do
|
11
11
|
expect(subject.get(nil)).to be_nil
|
12
12
|
expect(subject.get("full")).to be_nil
|
13
13
|
end
|
14
|
+
it "should return symbol for featured" do
|
15
|
+
expect(subject.get("featured")).to eql(:featured)
|
16
|
+
end
|
14
17
|
end
|
15
18
|
describe "with an absolute region" do
|
16
19
|
it "should calculate a contained region" 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.2
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-opencv
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/imogen/iiif/tiles.rb
|
57
57
|
- lib/imogen/zoomable.rb
|
58
58
|
- spec/spec_helper.rb
|
59
|
+
- spec/unit/imogen_iiif_quality_spec.rb
|
59
60
|
- spec/unit/imogen_iiif_region_spec.rb
|
60
61
|
- spec/unit/imogen_iiif_rotate_spec.rb
|
61
62
|
- spec/unit/imogen_iiif_size_spec.rb
|