hydra-derivatives 3.1.4 → 3.2.0

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: f9fe68ff09c49cf6061b2ef193ad428302dfac25
4
- data.tar.gz: 1c0d21de93c9616a4d97cf4b8f6c46f68a66d96e
3
+ metadata.gz: 9dc0683193a0c13d024d66551a3532a95cc107d5
4
+ data.tar.gz: f78c24977c2dfd89526c4f533fd9c2173b89f234
5
5
  SHA512:
6
- metadata.gz: 62bc8d5e8265a6f85214a530af6a6d36469473db17485b36a1cd622822ae591208ea5fa994ff2b23b4c1f5ab31d20131deb98061348941c47599be0ca403a2ee
7
- data.tar.gz: d74669b4b6ec7c9b713ee33b72f35e7d43f4acfbc44a675ef162b6e8194c2df0363f17d9da958441209587118cdaa34b2d7c35688752a489acc6d563a1b76994
6
+ metadata.gz: eb535231a681ff02ac2b001cea44b1808e7e5118eab1ba83ebd2762c3f8d56e47d9ec09d63d2a3d7771569dc45ae9439d5646adbe6e440878433f4f5b1470d62
7
+ data.tar.gz: 485d2b03e2ea10ea43dd9e2836f43bc0823f190a19a6d5763d86356b37a11724c6a8690b72a2791bede8a9cd96f64a631edb8bcfb787eb1232e5098046199ba0
@@ -17,6 +17,5 @@ notifications:
17
17
  irc:
18
18
  channels:
19
19
  - "irc.freenode.org#scholarsphere"
20
- - "irc.freenode.org#projecthydra"
21
20
  template:
22
21
  - "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
data/History.md CHANGED
@@ -1,3 +1,41 @@
1
+ ## 3.2.0 (2016-11-16)
2
+ 2016-11-08: Directive option for layer [Adam Wead]
3
+
4
+ ## 3.1.4 (2016-10-13)
5
+ 2016-10-13: Convert documents to pdf and jpg, fixes #109 [Adam Wead]
6
+
7
+ 2016-09-30: Flatten images when resizing, fixes #110 [Adam Wead]
8
+
9
+ 2016-09-29: Adding Rubocop to manage our style [Adam Wead]
10
+
11
+ ## 3.1.3 (2016-09-13)
12
+ 2016-09-13: Loosen dependecy to allow active-fedora 11 [Justin Coyne]
13
+
14
+ ## 3.1.2 (2016-08-09)
15
+ 2016-07-28: Bumping version of Ruby to 2.2.5 for updated ActiveSupport [Esmé Cowles]
16
+
17
+ 2016-07-11: Allow for Rails 5 [Trey Pendragon]
18
+
19
+ ## 3.1.1 (2016-05-18)
20
+ 2016-05-10: Use `Dir.tmpdir` to get a platform-specific tmp dir [Chris Beer]
21
+
22
+ ## 3.1.0 (2016-05-10)
23
+ 2016-05-10: Allow hydra-derivatives to work with active-fedora 10 [Justin Coyne]
24
+
25
+ 2016-05-10: Update solr schema for Solr 6 compatibility [Chris Beer]
26
+
27
+ ## 3.0.2 (2016-05-04)
28
+ 2016-04-26: Update FITS version in README [Michael J. Giarlo]
29
+
30
+ ## 3.0.1 (2016-03-24)
31
+ 2016-03-24: Solr/Fedora Wrapper [Trey Pendragon]
32
+
33
+ 2016-03-24: Allow for Mime-Types 3.0 [Trey Pendragon]
34
+
35
+ 2015-10-21: Silence Kakadu messages. [Trey Terrell]
36
+
37
+ 2015-10-20: Fix srgb_profile_path. [Trey Terrell]
38
+
1
39
  ## 3.0.0 (2015-10-07)
2
40
  2015-10-07: Update to the containerized builds on travis [Justin Coyne]
3
41
 
data/README.md CHANGED
@@ -83,6 +83,18 @@ Hydra::Derivatives::Video::Processor.config.mkv.codec = '-vcodec ffv1'
83
83
  Hydra::Derivatives::Video::Processor.config.jpeg.codec = '-vcodec mjpeg'
84
84
  ```
85
85
 
86
+ ### Additional Directives
87
+
88
+ #### Layers
89
+
90
+ When processing pdf files or images that may contain layers, you can select which layer you want
91
+ to use. This is especially useful with multipage pdf files, which are flattened to ensure the
92
+ background is correctly rendered. To choose the first layer or page for a pdf:
93
+
94
+ ```
95
+ PdfDerivatives.create(filename, outputs: [{ label: :thumb, size: "100x100>", layer: 0 }]
96
+ ```
97
+
86
98
  # Installation
87
99
 
88
100
  Just add `gem 'hydra-derivatives'` to your Gemfile.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.4
1
+ 3.2.0
@@ -28,7 +28,7 @@ module Hydra::Derivatives::Processors
28
28
  end
29
29
 
30
30
  def create_image
31
- xfrm = load_image_transformer
31
+ xfrm = selected_layers(load_image_transformer)
32
32
  yield(xfrm) if block_given?
33
33
  xfrm.format(directives.fetch(:format))
34
34
  xfrm.quality(quality.to_s) if quality
@@ -57,5 +57,11 @@ module Hydra::Derivatives::Processors
57
57
  def quality
58
58
  directives.fetch(:quality, nil)
59
59
  end
60
+
61
+ def selected_layers(image)
62
+ layer_index = directives.fetch(:layer, false)
63
+ return image unless layer_index
64
+ image.layers[layer_index]
65
+ end
60
66
  end
61
67
  end
@@ -5,20 +5,38 @@ 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
- let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
9
8
  let(:mock_transformer) { double("MockTransformer") }
9
+ let(:mock_layer) { double("MockLayer") }
10
10
 
11
- before do
12
- allow(subject).to receive(:load_image_transformer).and_return(mock_transformer)
13
- allow(subject).to receive(:write_image).with(mock_transformer)
11
+ before { allow(subject).to receive(:load_image_transformer).and_return(mock_transformer) }
12
+
13
+ context "using image directives" do
14
+ let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
15
+
16
+ before { allow(subject).to receive(:write_image).with(mock_transformer) }
17
+
18
+ it "uses the specified size and name and quality" do
19
+ expect(mock_transformer).to receive(:flatten)
20
+ expect(mock_transformer).to receive(:resize).with("200x300>")
21
+ expect(mock_transformer).to receive(:format).with("png")
22
+ expect(mock_transformer).to receive(:quality).with("75")
23
+ subject.process
24
+ end
14
25
  end
15
26
 
16
- it "uses the specified size and name and quality" do
17
- expect(mock_transformer).to receive(:flatten)
18
- expect(mock_transformer).to receive(:resize).with("200x300>")
19
- expect(mock_transformer).to receive(:format).with("png")
20
- expect(mock_transformer).to receive(:quality).with("75")
21
- subject.process
27
+ context "using pdf directives" do
28
+ let(:directives) { { label: :thumb, size: "200x300>", format: 'pdf', layer: 0, quality: 75 } }
29
+
30
+ before { allow(subject).to receive(:write_image).with(mock_layer) }
31
+
32
+ it "uses the specified size and name and quality" do
33
+ expect(mock_transformer).to receive(:layers).and_return([mock_layer])
34
+ expect(mock_layer).to receive(:flatten)
35
+ expect(mock_layer).to receive(:resize).with("200x300>")
36
+ expect(mock_layer).to receive(:format).with("pdf")
37
+ expect(mock_layer).to receive(:quality).with("75")
38
+ subject.process
39
+ end
22
40
  end
23
41
  end
24
42
 
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.1.4
4
+ version: 3.2.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: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler