hydra-derivatives 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +3 -0
- data/README.md +4 -2
- data/VERSION +1 -1
- data/lib/hydra/derivatives/processors/image.rb +7 -3
- data/spec/processors/image_spec.rb +71 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4f7de97aeaa9148272e2cc1e4d16bba7d33f4f
|
4
|
+
data.tar.gz: 867caa37665a6e477ab511435b501124b63f852a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcc289306fd1d503078e74e149f3dc252f0b55c60e735fe9f650cd636e88d9be78d929f71ea3df138e30ae54bc1a166e22b447282bb2e644c44db64b9e70f07d
|
7
|
+
data.tar.gz: 2a0396315ec846b9a1457561810cf6c0decf3bed5b45a4f409854e8ab6df78de6a4600acab934494e78f2f3395bbd95f66f1f85f8ded36178025e8bddff9807b
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -89,10 +89,12 @@ Hydra::Derivatives::Video::Processor.config.jpeg.codec = '-vcodec mjpeg'
|
|
89
89
|
|
90
90
|
When processing pdf files or images that may contain layers, you can select which layer you want
|
91
91
|
to use. This is especially useful with multipage pdf files, which are flattened to ensure the
|
92
|
-
background is correctly rendered.
|
92
|
+
background is correctly rendered. By default, the first page, or layer 0, is chosen when creating
|
93
|
+
images from pdf files. If you want to choose a different page, such as the second page, you can
|
94
|
+
set the layer directive:
|
93
95
|
|
94
96
|
```
|
95
|
-
PdfDerivatives.create(filename, outputs: [{ label: :thumb, size: "100x100>", layer:
|
97
|
+
PdfDerivatives.create(filename, outputs: [{ label: :thumb, size: "100x100>", layer: 1 }]
|
96
98
|
```
|
97
99
|
|
98
100
|
# Installation
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.1
|
@@ -59,9 +59,13 @@ module Hydra::Derivatives::Processors
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def selected_layers(image)
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
if image.type =~ /pdf/i
|
63
|
+
image.layers[directives.fetch(:layer, 0)]
|
64
|
+
elsif directives.fetch(:layer, false)
|
65
|
+
image.layers[directives.fetch(:layer)]
|
66
|
+
else
|
67
|
+
image
|
68
|
+
end
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
@@ -5,37 +5,86 @@ describe Hydra::Derivatives::Processors::Image do
|
|
5
5
|
subject { described_class.new(file_name, directives) }
|
6
6
|
|
7
7
|
context "when arguments are passed as a hash" do
|
8
|
-
|
9
|
-
let(:mock_layer) { double("MockLayer") }
|
8
|
+
before { allow(subject).to receive(:load_image_transformer).and_return(mock_image) }
|
10
9
|
|
11
|
-
|
10
|
+
context "with a multi-page pdf source file" do
|
11
|
+
let(:first_page) { double("MockPage") }
|
12
|
+
let(:second_page) { double("MockPage") }
|
13
|
+
let(:mock_image) { double("MockImageOfPdf", layers: [first_page, second_page]) }
|
12
14
|
|
13
|
-
|
14
|
-
let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
|
15
|
+
before { allow(mock_image).to receive(:type).and_return("PDF") }
|
15
16
|
|
16
|
-
|
17
|
+
context "by default" do
|
18
|
+
let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
it "uses the first page" do
|
21
|
+
expect(first_page).to receive(:flatten)
|
22
|
+
expect(second_page).not_to receive(:flatten)
|
23
|
+
expect(first_page).to receive(:resize).with("200x300>")
|
24
|
+
expect(second_page).not_to receive(:resize)
|
25
|
+
expect(first_page).to receive(:format).with("png")
|
26
|
+
expect(second_page).not_to receive(:format)
|
27
|
+
expect(first_page).to receive(:quality).with("75")
|
28
|
+
expect(second_page).not_to receive(:quality)
|
29
|
+
expect(subject).to receive(:write_image).with(first_page)
|
30
|
+
subject.process
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when specifying a layer" do
|
35
|
+
let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75, layer: 1 } }
|
36
|
+
|
37
|
+
it "uses the second page" do
|
38
|
+
expect(second_page).to receive(:flatten)
|
39
|
+
expect(first_page).not_to receive(:flatten)
|
40
|
+
expect(second_page).to receive(:resize).with("200x300>")
|
41
|
+
expect(first_page).not_to receive(:resize)
|
42
|
+
expect(second_page).to receive(:format).with("png")
|
43
|
+
expect(first_page).not_to receive(:format)
|
44
|
+
expect(second_page).to receive(:quality).with("75")
|
45
|
+
expect(first_page).not_to receive(:quality)
|
46
|
+
expect(subject).to receive(:write_image).with(second_page)
|
47
|
+
subject.process
|
48
|
+
end
|
24
49
|
end
|
25
50
|
end
|
26
51
|
|
27
|
-
context "
|
28
|
-
|
52
|
+
context "with an image source file" do
|
53
|
+
before { allow(mock_image).to receive(:type).and_return("JPEG") }
|
29
54
|
|
30
|
-
|
55
|
+
context "by default" do
|
56
|
+
let(:mock_image) { double("MockImage") }
|
57
|
+
let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
|
31
58
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
59
|
+
it "uses the image file" do
|
60
|
+
expect(mock_image).not_to receive(:layers)
|
61
|
+
expect(mock_image).to receive(:flatten)
|
62
|
+
expect(mock_image).to receive(:resize).with("200x300>")
|
63
|
+
expect(mock_image).to receive(:format).with("png")
|
64
|
+
expect(mock_image).to receive(:quality).with("75")
|
65
|
+
expect(subject).to receive(:write_image).with(mock_image)
|
66
|
+
subject.process
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when specifying a layer" do
|
71
|
+
let(:first_layer) { double("MockPage") }
|
72
|
+
let(:second_layer) { double("MockPage") }
|
73
|
+
let(:mock_image) { double("MockImage", layers: [first_layer, second_layer]) }
|
74
|
+
let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75, layer: 1 } }
|
75
|
+
|
76
|
+
it "uses the layer" do
|
77
|
+
expect(second_layer).to receive(:flatten)
|
78
|
+
expect(first_layer).not_to receive(:flatten)
|
79
|
+
expect(second_layer).to receive(:resize).with("200x300>")
|
80
|
+
expect(first_layer).not_to receive(:resize)
|
81
|
+
expect(second_layer).to receive(:format).with("png")
|
82
|
+
expect(first_layer).not_to receive(:format)
|
83
|
+
expect(second_layer).to receive(:quality).with("75")
|
84
|
+
expect(first_layer).not_to receive(:quality)
|
85
|
+
expect(subject).to receive(:write_image).with(second_layer)
|
86
|
+
subject.process
|
87
|
+
end
|
39
88
|
end
|
40
89
|
end
|
41
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-derivatives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.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-11-
|
11
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|