riiif 2.0.0.beta2 → 2.0.0

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.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +2 -11
  3. data/.rubocop_todo.yml +76 -33
  4. data/README.md +17 -2
  5. data/app/controllers/riiif/images_controller.rb +8 -2
  6. data/app/models/riiif/image.rb +15 -20
  7. data/app/models/riiif/image_information.rb +12 -24
  8. data/app/services/riiif/crop.rb +99 -30
  9. data/app/services/riiif/image_magick_info_extractor.rb +9 -2
  10. data/app/services/riiif/imagemagick_command_factory.rb +9 -4
  11. data/app/services/riiif/kakadu_command_factory.rb +2 -2
  12. data/app/services/riiif/resize.rb +72 -7
  13. data/app/transformers/riiif/kakadu_transformer.rb +25 -2
  14. data/docs/benchmark.md +75 -0
  15. data/lib/riiif/engine.rb +2 -1
  16. data/lib/riiif/routes.rb +3 -0
  17. data/lib/riiif/version.rb +1 -1
  18. data/riiif.gemspec +3 -3
  19. data/spec/controllers/riiif/images_controller_spec.rb +14 -3
  20. data/spec/models/riiif/image_information_spec.rb +2 -10
  21. data/spec/models/riiif/image_spec.rb +10 -16
  22. data/spec/services/riiif/imagemagick_command_factory_spec.rb +6 -6
  23. data/spec/services/riiif/kakadu_command_factory_spec.rb +15 -15
  24. data/spec/transformers/riiif/kakadu_transformer_spec.rb +22 -22
  25. metadata +24 -46
  26. data/app/models/riiif/transformation.rb +0 -35
  27. data/app/services/riiif/imagemagick_transformer.rb +0 -8
  28. data/app/services/riiif/option_decoder.rb +0 -88
  29. data/app/services/riiif/region/absolute.rb +0 -23
  30. data/app/services/riiif/region/full.rb +0 -23
  31. data/app/services/riiif/region/percentage.rb +0 -68
  32. data/app/services/riiif/region/square.rb +0 -45
  33. data/app/services/riiif/size/absolute.rb +0 -39
  34. data/app/services/riiif/size/best_fit.rb +0 -18
  35. data/app/services/riiif/size/full.rb +0 -17
  36. data/app/services/riiif/size/height.rb +0 -24
  37. data/app/services/riiif/size/percent.rb +0 -44
  38. data/app/services/riiif/size/width.rb +0 -24
  39. data/spec/models/riiif/transformation_spec.rb +0 -42
  40. data/spec/services/riiif/region/absolute_spec.rb +0 -17
  41. data/spec/services/riiif/size/absolute_spec.rb +0 -17
  42. data/spec/services/riiif/size/height_spec.rb +0 -13
  43. data/spec/services/riiif/size/width_spec.rb +0 -13
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Riiif::ImagemagickCommandFactory do
4
4
  let(:path) { 'foo.tiff' }
5
- let(:info) { double('foo') }
5
+ let(:info) { double(height: 100, width: 100, format: 'JPEG') }
6
6
 
7
7
  describe '.command' do
8
8
  subject { instance.command }
9
9
  let(:instance) { described_class.new(path, info, transformation) }
10
10
 
11
11
  let(:transformation) do
12
- Riiif::Transformation.new(Riiif::Region::Full.new(info),
13
- Riiif::Size::Full.new,
14
- 'quality',
15
- 'rotation',
16
- format)
12
+ IIIF::Image::Transformation.new(region: IIIF::Image::Region::Full.new,
13
+ size: IIIF::Image::Size::Full.new,
14
+ quality: 'quality',
15
+ rotation: 15.2,
16
+ format: format)
17
17
  end
18
18
 
19
19
  context "when it's a jpeg" do
@@ -7,18 +7,18 @@ RSpec.describe Riiif::KakaduCommandFactory do
7
7
 
8
8
  let(:info) { double(:info) }
9
9
  let(:path) { 'foo.jp2' }
10
- let(:region) { Riiif::Region::Full.new(info) }
11
- let(:size) { Riiif::Size::Full.new }
10
+ let(:region) { IIIF::Image::Region::Full.new }
11
+ let(:size) { IIIF::Image::Size::Full.new }
12
12
  let(:quality) { nil }
13
13
  let(:rotation) { nil }
14
14
  let(:fmt) { nil }
15
15
 
16
16
  let(:transformation) do
17
- Riiif::Transformation.new(region,
18
- size,
19
- quality,
20
- rotation,
21
- fmt)
17
+ IIIF::Image::Transformation.new(region: region,
18
+ size: size,
19
+ quality: quality,
20
+ rotation: rotation,
21
+ format: fmt)
22
22
  end
23
23
 
24
24
  describe '#command' do
@@ -38,17 +38,17 @@ RSpec.describe Riiif::KakaduCommandFactory do
38
38
  end
39
39
 
40
40
  context 'with absolute' do
41
- let(:region) { Riiif::Region::Absolute.new(info, 25, 75, 150, 100) }
41
+ let(:region) { IIIF::Image::Region::Absolute.new(25, 75, 150, 100) }
42
42
  it { is_expected.to eq ' -region "{0.25,0.08333333333333333},{0.3333333333333333,0.5}"' }
43
43
  end
44
44
 
45
45
  context 'with a square' do
46
- let(:region) { Riiif::Region::Square.new(info) }
46
+ let(:region) { IIIF::Image::Region::Square.new }
47
47
  it { is_expected.to eq ' -region "{0.0,0},{1.0,1.0}"' }
48
48
  end
49
49
 
50
50
  context 'with a percentage' do
51
- let(:region) { Riiif::Region::Percentage.new(info, 20, 30, 40, 50) }
51
+ let(:region) { IIIF::Image::Region::Percent.new(20.0, 30.0, 40.0, 50.0) }
52
52
  it { is_expected.to eq ' -region "{0.3,0.2},{0.5,0.4}"' }
53
53
  end
54
54
  end
@@ -56,29 +56,29 @@ RSpec.describe Riiif::KakaduCommandFactory do
56
56
  describe '#reduction_factor' do
57
57
  subject { instance.send(:reduction_factor) }
58
58
 
59
- let(:info) { Riiif::ImageInformation.new(300, 300) }
59
+ let(:info) { Riiif::ImageInformation.new(width: 300, height: 300) }
60
60
 
61
61
  context 'for a full size image' do
62
62
  it { is_expected.to eq nil }
63
63
  end
64
64
 
65
65
  context 'when the aspect ratio is maintined for absolute' do
66
- let(:size) { Riiif::Size::Absolute.new(info, 145, 145) }
66
+ let(:size) { IIIF::Image::Size::Absolute.new(145, 145) }
67
67
  it { is_expected.to eq 1 }
68
68
  end
69
69
 
70
70
  context 'when the aspect ratio is not-maintined' do
71
- let(:size) { Riiif::Size::Absolute.new(info, 100, 145) }
71
+ let(:size) { IIIF::Image::Size::Absolute.new(100, 145) }
72
72
  it { is_expected.to eq nil }
73
73
  end
74
74
 
75
75
  context 'when aspect ratio is maintained for 45 pct' do
76
- let(:size) { Riiif::Size::Percent.new(info, 45) }
76
+ let(:size) { IIIF::Image::Size::Percent.new(45.0) }
77
77
  it { is_expected.to eq 1 }
78
78
  end
79
79
 
80
80
  context 'when aspect ratio is maintained for 20 pct' do
81
- let(:size) { Riiif::Size::Percent.new(info, 20) }
81
+ let(:size) { IIIF::Image::Size::Percent.new(20.0) }
82
82
  it { is_expected.to eq 2 }
83
83
  end
84
84
  end
@@ -5,20 +5,20 @@ require 'spec_helper'
5
5
  RSpec.describe Riiif::KakaduTransformer do
6
6
  subject(:instance) { described_class.new(path, image_info, transformation) }
7
7
 
8
- let(:image_info) { Riiif::ImageInformation.new(6501, 4381) }
8
+ let(:image_info) { Riiif::ImageInformation.new(width: 6501, height: 4381) }
9
9
  let(:path) { 'baseball.jp2' }
10
- let(:region) { Riiif::Region::Full.new(image_info) }
11
- let(:size) { Riiif::Size::Full.new }
10
+ let(:region) { IIIF::Image::Region::Full.new }
11
+ let(:size) { IIIF::Image::Size::Full.new }
12
12
  let(:quality) { nil }
13
- let(:rotation) { nil }
13
+ let(:rotation) { 0 }
14
14
  let(:fmt) { 'jpg' }
15
15
 
16
16
  let(:transformation) do
17
- Riiif::Transformation.new(region,
18
- size,
19
- quality,
20
- rotation,
21
- fmt)
17
+ IIIF::Image::Transformation.new(region: region,
18
+ size: size,
19
+ quality: quality,
20
+ rotation: rotation,
21
+ format: fmt)
22
22
  end
23
23
 
24
24
  describe '#transform' do
@@ -32,10 +32,10 @@ RSpec.describe Riiif::KakaduTransformer do
32
32
 
33
33
  context 'resize and region' do
34
34
  # This is the validator test for size_region
35
- let(:size) { Riiif::Size::Absolute.new(image_info, 38, 38) }
36
- let(:region) { Riiif::Region::Absolute.new(image_info, 200, 100, 100, 100) }
35
+ let(:size) { IIIF::Image::Size::Absolute.new(38, 38) }
36
+ let(:region) { IIIF::Image::Region::Absolute.new(200, 100, 100, 100) }
37
37
 
38
- let(:image_info) { Riiif::ImageInformation.new(1000, 1000) }
38
+ let(:image_info) { Riiif::ImageInformation.new(width: 1000, height: 1000) }
39
39
 
40
40
  it 'calls the Imagemagick transform' do
41
41
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -60,8 +60,8 @@ RSpec.describe Riiif::KakaduTransformer do
60
60
  end
61
61
 
62
62
  context 'and size is a width' do
63
- let(:size) { Riiif::Size::Width.new(image_info, 651) }
64
- let(:image_info) { Riiif::ImageInformation.new(1000, 1000) }
63
+ let(:size) { IIIF::Image::Size::Width.new(651) }
64
+ let(:image_info) { Riiif::ImageInformation.new(width: 1000, height: 1000) }
65
65
 
66
66
  it 'calls the Imagemagick transform' do
67
67
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -73,8 +73,8 @@ RSpec.describe Riiif::KakaduTransformer do
73
73
  end
74
74
 
75
75
  context 'and size is a height' do
76
- let(:size) { Riiif::Size::Height.new(image_info, 581) }
77
- let(:image_info) { Riiif::ImageInformation.new(1000, 1000) }
76
+ let(:size) { IIIF::Image::Size::Height.new(581) }
77
+ let(:image_info) { Riiif::ImageInformation.new(width: 1000, height: 1000) }
78
78
 
79
79
  it 'calls the Imagemagick transform' do
80
80
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -90,7 +90,7 @@ RSpec.describe Riiif::KakaduTransformer do
90
90
  let(:reduction_factor) { 1 }
91
91
 
92
92
  context 'and size is a Percent' do
93
- let(:size) { Riiif::Size::Percent.new(image_info, 30) }
93
+ let(:size) { IIIF::Image::Size::Percent.new(30.0) }
94
94
 
95
95
  it 'calls the Imagemagick transform' do
96
96
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -102,8 +102,8 @@ RSpec.describe Riiif::KakaduTransformer do
102
102
  end
103
103
 
104
104
  context 'and size is a width' do
105
- let(:size) { Riiif::Size::Width.new(image_info, 408) }
106
- let(:image_info) { Riiif::ImageInformation.new(1000, 1000) }
105
+ let(:size) { IIIF::Image::Size::Width.new(408) }
106
+ let(:image_info) { Riiif::ImageInformation.new(width: 1000, height: 1000) }
107
107
 
108
108
  it 'calls the Imagemagick transform' do
109
109
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -115,8 +115,8 @@ RSpec.describe Riiif::KakaduTransformer do
115
115
  end
116
116
 
117
117
  context 'and size is a height' do
118
- let(:size) { Riiif::Size::Height.new(image_info, 481) }
119
- let(:image_info) { Riiif::ImageInformation.new(1000, 1000) }
118
+ let(:size) { IIIF::Image::Size::Height.new(481) }
119
+ let(:image_info) { Riiif::ImageInformation.new(width: 1000, height: 1000) }
120
120
 
121
121
  it 'calls the Imagemagick transform' do
122
122
  expect(Riiif::CommandRunner).to receive(:execute)
@@ -129,7 +129,7 @@ RSpec.describe Riiif::KakaduTransformer do
129
129
  end
130
130
 
131
131
  context 'when reduction_factor is 2' do
132
- let(:size) { Riiif::Size::Percent.new(image_info, 20) }
132
+ let(:size) { IIIF::Image::Size::Percent.new(20.0) }
133
133
  let(:reduction_factor) { 2 }
134
134
  it 'calls the Imagemagick transform' do
135
135
  expect(Riiif::CommandRunner).to receive(:execute)
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: 2.0.0.beta2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-09 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: iiif-image-api
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.1.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.1.0
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: bundler
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -115,33 +129,19 @@ dependencies:
115
129
  - !ruby/object:Gem::Version
116
130
  version: '0'
117
131
  - !ruby/object:Gem::Dependency
118
- name: rubocop
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 0.47.1
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: 0.47.1
131
- - !ruby/object:Gem::Dependency
132
- name: rubocop-rspec
132
+ name: bixby
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '1.13'
137
+ version: 1.0.0
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '1.13'
144
+ version: 1.0.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: coveralls
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -158,7 +158,7 @@ dependencies:
158
158
  version: '0'
159
159
  description: A IIIF image server
160
160
  email:
161
- - justin@curationexperts.com
161
+ - administrator@curationexperts.com
162
162
  executables: []
163
163
  extensions: []
164
164
  extra_rdoc_files: []
@@ -177,7 +177,6 @@ files:
177
177
  - app/models/riiif/file.rb
178
178
  - app/models/riiif/image.rb
179
179
  - app/models/riiif/image_information.rb
180
- - app/models/riiif/transformation.rb
181
180
  - app/resolvers/riiif/abstract_file_system_resolver.rb
182
181
  - app/resolvers/riiif/akubra_system_file_resolver.rb
183
182
  - app/resolvers/riiif/file_system_file_resolver.rb
@@ -186,26 +185,15 @@ files:
186
185
  - app/services/riiif/crop.rb
187
186
  - app/services/riiif/image_magick_info_extractor.rb
188
187
  - app/services/riiif/imagemagick_command_factory.rb
189
- - app/services/riiif/imagemagick_transformer.rb
190
188
  - app/services/riiif/kakadu_command_factory.rb
191
189
  - app/services/riiif/link_name_service.rb
192
190
  - app/services/riiif/nil_authorization_service.rb
193
- - app/services/riiif/option_decoder.rb
194
- - app/services/riiif/region/absolute.rb
195
- - app/services/riiif/region/full.rb
196
- - app/services/riiif/region/percentage.rb
197
- - app/services/riiif/region/square.rb
198
191
  - app/services/riiif/resize.rb
199
- - app/services/riiif/size/absolute.rb
200
- - app/services/riiif/size/best_fit.rb
201
- - app/services/riiif/size/full.rb
202
- - app/services/riiif/size/height.rb
203
- - app/services/riiif/size/percent.rb
204
- - app/services/riiif/size/width.rb
205
192
  - app/transformers/riiif/abstract_transformer.rb
206
193
  - app/transformers/riiif/imagemagick_transformer.rb
207
194
  - app/transformers/riiif/kakadu_transformer.rb
208
195
  - config/routes.rb
196
+ - docs/benchmark.md
209
197
  - lib/riiif.rb
210
198
  - lib/riiif/engine.rb
211
199
  - lib/riiif/rails/routes.rb
@@ -218,15 +206,10 @@ files:
218
206
  - spec/models/riiif/http_file_resolver_spec.rb
219
207
  - spec/models/riiif/image_information_spec.rb
220
208
  - spec/models/riiif/image_spec.rb
221
- - spec/models/riiif/transformation_spec.rb
222
209
  - spec/routing/redirect_spec.rb
223
210
  - spec/routing/resize_routes_spec.rb
224
211
  - spec/services/riiif/imagemagick_command_factory_spec.rb
225
212
  - spec/services/riiif/kakadu_command_factory_spec.rb
226
- - spec/services/riiif/region/absolute_spec.rb
227
- - spec/services/riiif/size/absolute_spec.rb
228
- - spec/services/riiif/size/height_spec.rb
229
- - spec/services/riiif/size/width_spec.rb
230
213
  - spec/spec_helper.rb
231
214
  - spec/test_app_templates/Gemfile.extra
232
215
  - spec/test_app_templates/lib/generators/test_app_generator.rb
@@ -246,12 +229,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
229
  version: '0'
247
230
  required_rubygems_version: !ruby/object:Gem::Requirement
248
231
  requirements:
249
- - - ">"
232
+ - - ">="
250
233
  - !ruby/object:Gem::Version
251
- version: 1.3.1
234
+ version: '0'
252
235
  requirements: []
253
236
  rubyforge_project:
254
- rubygems_version: 2.6.13
237
+ rubygems_version: 2.7.6
255
238
  signing_key:
256
239
  specification_version: 4
257
240
  summary: A rails engine that support IIIF requests
@@ -262,15 +245,10 @@ test_files:
262
245
  - spec/models/riiif/http_file_resolver_spec.rb
263
246
  - spec/models/riiif/image_information_spec.rb
264
247
  - spec/models/riiif/image_spec.rb
265
- - spec/models/riiif/transformation_spec.rb
266
248
  - spec/routing/redirect_spec.rb
267
249
  - spec/routing/resize_routes_spec.rb
268
250
  - spec/services/riiif/imagemagick_command_factory_spec.rb
269
251
  - spec/services/riiif/kakadu_command_factory_spec.rb
270
- - spec/services/riiif/region/absolute_spec.rb
271
- - spec/services/riiif/size/absolute_spec.rb
272
- - spec/services/riiif/size/height_spec.rb
273
- - spec/services/riiif/size/width_spec.rb
274
252
  - spec/spec_helper.rb
275
253
  - spec/test_app_templates/Gemfile.extra
276
254
  - spec/test_app_templates/lib/generators/test_app_generator.rb
@@ -1,35 +0,0 @@
1
- module Riiif
2
- # Represents a IIIF request
3
- class Transformation
4
- attr_reader :crop, :size, :quality, :rotation, :format
5
- def initialize(crop, size, quality, rotation, format)
6
- @crop = crop
7
- @size = size
8
- @quality = quality
9
- @rotation = rotation
10
- @format = format
11
- end
12
-
13
- # Create a clone of this Transformation, scaled by the factor
14
- # @param [Integer] factor the scale for the new transformation
15
- # @return [Transformation] a new transformation, scaled by factor
16
- def reduce(factor)
17
- Transformation.new(crop.dup,
18
- size.reduce(factor),
19
- quality,
20
- rotation,
21
- format)
22
- end
23
-
24
- # Create a clone of this Transformation, without the crop
25
- # @return [Transformation] a new transformation
26
- # TODO: it would be nice if we didn't need image_info
27
- def without_crop(image_info)
28
- Transformation.new(Region::Full.new(image_info),
29
- size.dup,
30
- quality,
31
- rotation,
32
- format)
33
- end
34
- end
35
- end
@@ -1,8 +0,0 @@
1
- module Riiif
2
- # Transforms an image using Imagemagick
3
- class ImagemagickTransformer < AbstractTransformer
4
- def command_factory
5
- ImagemagickCommandFactory
6
- end
7
- end
8
- end
@@ -1,88 +0,0 @@
1
- module Riiif
2
- # Decodes the URL parameters into a Transformation object
3
- class OptionDecoder
4
- OUTPUT_FORMATS = %w(jpg png).freeze
5
-
6
- # a helper method for instantiating the OptionDecoder
7
- # @param [ActiveSupport::HashWithIndifferentAccess] options
8
- # @param [ImageInformation] image_info
9
- def self.decode(options, image_info)
10
- new(options, image_info).decode
11
- end
12
-
13
- # @param [ActiveSupport::HashWithIndifferentAccess] options
14
- # @param [ImageInformation] image_info
15
- def initialize(options, image_info)
16
- @options = options
17
- @image_info = image_info
18
- end
19
-
20
- attr_reader :image_info
21
-
22
- ##
23
- # @return [Transformation]
24
- def decode
25
- raise ArgumentError, "You must provide a format. You provided #{@options}" unless @options[:format]
26
- validate_format!(@options[:format])
27
- Riiif::Transformation.new(decode_region(@options.delete(:region)),
28
- decode_size(@options.delete(:size)),
29
- decode_quality(@options[:quality]),
30
- decode_rotation(@options[:rotation]),
31
- @options[:format])
32
- end
33
-
34
- def decode_quality(quality)
35
- return if quality.nil? || %w(default color).include?(quality)
36
- return quality if %w(bitonal grey).include?(quality)
37
- raise InvalidAttributeError, "Unsupported quality: #{quality}"
38
- end
39
-
40
- def decode_rotation(rotation)
41
- return if rotation.nil? || rotation == '0'
42
- begin
43
- Float(rotation)
44
- rescue ArgumentError
45
- raise InvalidAttributeError, "Unsupported rotation: #{rotation}"
46
- end
47
- end
48
-
49
- def validate_format!(format)
50
- raise InvalidAttributeError, "Unsupported format: #{format}" unless OUTPUT_FORMATS.include?(format)
51
- end
52
-
53
- def decode_region(region)
54
- if region.nil? || region == 'full'
55
- Riiif::Region::Full.new(image_info)
56
- elsif md = /^pct:(\d+),(\d+),(\d+),(\d+)$/.match(region)
57
- Riiif::Region::Percentage
58
- .new(image_info, md[1], md[2], md[3], md[4])
59
- elsif md = /^(\d+),(\d+),(\d+),(\d+)$/.match(region)
60
- Riiif::Region::Absolute.new(image_info, md[1], md[2], md[3], md[4])
61
- elsif region == 'square'
62
- Riiif::Region::Square.new(image_info)
63
- else
64
- raise InvalidAttributeError, "Invalid region: #{region}"
65
- end
66
- end
67
-
68
- # rubocop:disable Metrics/PerceivedComplexity
69
- def decode_size(size)
70
- if size.nil? || size == 'full'
71
- Riiif::Size::Full.new
72
- elsif md = /^,(\d+)$/.match(size)
73
- Riiif::Size::Height.new(image_info, md[1])
74
- elsif md = /^(\d+),$/.match(size)
75
- Riiif::Size::Width.new(image_info, md[1])
76
- elsif md = /^pct:(\d+(.\d+)?)$/.match(size)
77
- Riiif::Size::Percent.new(image_info, md[1])
78
- elsif md = /^(\d+),(\d+)$/.match(size)
79
- Riiif::Size::Absolute.new(image_info, md[1], md[2])
80
- elsif md = /^!(\d+),(\d+)$/.match(size)
81
- Riiif::Size::BestFit.new(image_info, md[1], md[2])
82
- else
83
- raise InvalidAttributeError, "Invalid size: #{size}"
84
- end
85
- end
86
- # rubocop:enable Metrics/PerceivedComplexity
87
- end
88
- end