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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a1934121b4a1108f275c5a0331519770bb408eb
4
- data.tar.gz: eb9d3f833d1e77fe46421a754a2d8365eb081102
3
+ metadata.gz: 30f471dbabbb6d626cbc8477de2490b0ed732b8e
4
+ data.tar.gz: de3732ff0b0d71d96474e650fc1e72df8564e772
5
5
  SHA512:
6
- metadata.gz: 848a8082a7768d0011f3e13dedebd36987aebbf5fef0c77103f0847539550066a84bac07f526689a80bd2b2d6fbd09b31c0eb9b19b732fec06dcfa3d4512a6d2
7
- data.tar.gz: 58b1a338bf60c86fbba8b53fe7f340bab83d8a28bce65d7a84e2fab82bc2c79440340e498a1e52c248e7e5e5286dd3486a29638551298170a1d19d78e3958893
6
+ metadata.gz: b704b4e3a0c8fbda79a78b040f1d6dec12db688932ccdbfdaa8ce7b74419aa1a152930d6e2e7eeec2dfbaa51d52b77853651381a4709cb4f50164428f60f5092
7
+ data.tar.gz: 711c3a7639ac468462b88fbabe5840f0a6fe6c2bedd51a300bbd19404ff8dffca8a29d585a365a59cbe41db9fd4c453b4a91e84cf531a74172acab6fa11238c2
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Riiif
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
@@ -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.0
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 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails