riiif 1.4.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/app/services/riiif/image_magick_info_extractor.rb +5 -1
- data/app/services/riiif/imagemagick_command_factory.rb +5 -5
- data/lib/riiif/version.rb +1 -1
- data/spec/models/riiif/image_spec.rb +2 -2
- data/spec/services/riiif/imagemagick_command_factory_spec.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e630fd475317ef90d8bb9989f8ea82e7aa29bf
|
4
|
+
data.tar.gz: f61946e5c03cc23a82ea29457ad6dd9030488a2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82d4bf6a8c91cb17c3627bbdb488cc9c1d0e5788b2ef81f727c4d6d62c01de6ec1b671c9b7962bb7c02519706e22eeb791a3b25b026c57b9c3b9c3aeda5cadd4
|
7
|
+
data.tar.gz: 90e275799a60adf067aaf5f4ea1888a3d81e5855a3c9db15c3ccb75f690037ec942362588e707f3b2fa1bce11193253f6902ea8e933131b42b220cb682e7b0cf
|
data/README.md
CHANGED
@@ -63,6 +63,15 @@ This file resolver caches the network files, so you will want to clear out the o
|
|
63
63
|
Using a script like this would be a good idea: https://github.com/pulibrary/loris/blob/607567b921404a15a2111fbd7123604f4fdec087/bin/loris-cache_clean.sh
|
64
64
|
By default the cache is located in `tmp/network_files`. You can set the cache path like this: `Riiif::Image.file_resolver.cache_path = '/var/cache'`
|
65
65
|
|
66
|
+
### GraphicsMagick
|
67
|
+
|
68
|
+
To use [GraphicsMagick](http://www.graphicsmagick.org/) instead of ImageMagick
|
69
|
+
|
70
|
+
Riiif::ImagemagickCommandFactory.external_command = "gm convert"
|
71
|
+
Riiif::ImageMagickInfoExtractor.external_command = "gm identify"
|
72
|
+
|
73
|
+
You will of course need to install GraphicsMagick on your system.
|
74
|
+
|
66
75
|
## Usage
|
67
76
|
|
68
77
|
Add the routes to your application by inserting the following line into `config/routes.rb`
|
@@ -173,12 +182,12 @@ Riiif::Engine.config.cache_duration_in_days = 30
|
|
173
182
|
```
|
174
183
|
#### Special note for Passenger and Apache users
|
175
184
|
If you are running riiif in Passenger under Apache, you must set the following in your virtual host definition:
|
176
|
-
|
185
|
+
|
177
186
|
```
|
178
187
|
AllowEncodedSlashes NoDecode
|
179
188
|
```
|
180
189
|
|
181
|
-
You may also need to set the following in your virtual host definition, either at the top level, or within a
|
190
|
+
You may also need to set the following in your virtual host definition, either at the top level, or within a
|
182
191
|
Location block for a specific path. See the [Passenger configuration reference](https://www.phusionpassenger.com/library/config/apache/reference/#passengerallowencodedslasheshttps://www.phusionpassenger.com/library/config/apache/reference/#passengerallowencodedslashes) for more info.
|
183
192
|
|
184
193
|
```
|
@@ -1,12 +1,16 @@
|
|
1
1
|
module Riiif
|
2
2
|
# Get height and width information using imagemagick to interrogate the file
|
3
3
|
class ImageMagickInfoExtractor
|
4
|
+
# perhaps you want to use GraphicsMagick instead, set to "gm identify"
|
5
|
+
class_attribute :external_command
|
6
|
+
self.external_command = 'identify'
|
7
|
+
|
4
8
|
def initialize(path)
|
5
9
|
@path = path
|
6
10
|
end
|
7
11
|
|
8
12
|
def extract
|
9
|
-
height, width = Riiif::CommandRunner.execute("
|
13
|
+
height, width = Riiif::CommandRunner.execute("#{external_command} -format %hx%w #{@path}[0]").split('x')
|
10
14
|
{ height: Integer(height), width: Integer(width) }
|
11
15
|
end
|
12
16
|
end
|
@@ -3,6 +3,10 @@
|
|
3
3
|
module Riiif
|
4
4
|
# Builds a command to run a transformation using Imagemagick
|
5
5
|
class ImagemagickCommandFactory
|
6
|
+
# perhaps you want to use GraphicsMagick instead, set to "gm convert"
|
7
|
+
class_attribute :external_command
|
8
|
+
self.external_command = 'convert'
|
9
|
+
|
6
10
|
# A helper method to instantiate and invoke build
|
7
11
|
# @param [String] path the location of the file
|
8
12
|
# @param [Transformation] transformation
|
@@ -33,15 +37,11 @@ module Riiif
|
|
33
37
|
|
34
38
|
# @return [String] a command for running imagemagick to produce the requested output
|
35
39
|
def build
|
36
|
-
[
|
40
|
+
[external_command, crop, size, rotation, colorspace, quality, sampling, metadata, output].join
|
37
41
|
end
|
38
42
|
|
39
43
|
private
|
40
44
|
|
41
|
-
def command
|
42
|
-
'convert'
|
43
|
-
end
|
44
|
-
|
45
45
|
def use_compression?
|
46
46
|
compression > 0 && jpeg?
|
47
47
|
end
|
data/lib/riiif/version.rb
CHANGED
@@ -75,14 +75,14 @@ RSpec.describe Riiif::Image do
|
|
75
75
|
|
76
76
|
it 'handles percent geometry' do
|
77
77
|
expect(Riiif::CommandRunner).to receive(:execute)
|
78
|
-
.with("identify -format %hx%w #{filename}").and_return('131x175')
|
78
|
+
.with("identify -format %hx%w #{filename}[0]").and_return('131x175')
|
79
79
|
expect(Riiif::CommandRunner).to receive(:execute).with("convert -crop 80%x70+18+13 -strip #{filename} png:-")
|
80
80
|
subject.render(region: 'pct:10,10,80,70', format: 'png')
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'handles square geometry' do
|
84
84
|
expect(Riiif::CommandRunner).to receive(:execute)
|
85
|
-
.with("identify -format %hx%w #{filename}").and_return('131x175')
|
85
|
+
.with("identify -format %hx%w #{filename}[0]").and_return('131x175')
|
86
86
|
expect(Riiif::CommandRunner).to receive(:execute).with("convert -crop 131x131+22+0 -strip #{filename} png:-")
|
87
87
|
subject.render(region: 'square', format: 'png')
|
88
88
|
end
|
@@ -23,5 +23,19 @@ RSpec.describe Riiif::ImagemagickCommandFactory do
|
|
23
23
|
let(:format) { 'tif' }
|
24
24
|
it { is_expected.not_to match(/-quality/) }
|
25
25
|
end
|
26
|
+
|
27
|
+
describe '#external_command' do
|
28
|
+
let(:format) { 'jpg' }
|
29
|
+
around do |example|
|
30
|
+
orig = described_class.external_command
|
31
|
+
described_class.external_command = 'gm convert'
|
32
|
+
|
33
|
+
example.run
|
34
|
+
|
35
|
+
described_class.external_command = orig
|
36
|
+
end
|
37
|
+
|
38
|
+
it { is_expected.to match(/\Agm convert/) }
|
39
|
+
end
|
26
40
|
end
|
27
41
|
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: 1.
|
4
|
+
version: 1.5.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-
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
version: '0'
|
207
207
|
requirements: []
|
208
208
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.6.
|
209
|
+
rubygems_version: 2.6.8
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: A rails engine that support IIIF requests
|