assembly-image 1.7.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/image_spec.rb CHANGED
@@ -1,45 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
+ require 'fileutils'
4
5
 
5
6
  RSpec.describe Assembly::Image do
6
- let(:ai) { described_class.new(input_path) }
7
+ let(:assembly_image) { described_class.new(input_path) }
7
8
  let(:input_path) { TEST_TIF_INPUT_FILE }
9
+ let(:jp2_output_file) { File.join(TEST_OUTPUT_DIR, File.basename(input_path).gsub('.tif', '.jp2')) }
8
10
 
9
- after do
10
- # after each test, empty out the input and output test directories
11
- remove_files(TEST_INPUT_DIR)
12
- remove_files(TEST_OUTPUT_DIR)
13
- end
11
+ before { cleanup }
14
12
 
15
13
  describe '#jp2_filename' do
16
14
  it 'indicates the default jp2 filename' do
17
- expect(ai.jp2_filename).to eq TEST_TIF_INPUT_FILE.gsub('.tif', '.jp2')
15
+ expect(assembly_image.jp2_filename).to eq input_path.gsub('.tif', '.jp2')
18
16
  end
19
17
 
20
18
  context 'with a file with no extension' do
21
19
  let(:input_path) { '/path/to/a/file_with_no_extension' }
22
20
 
23
21
  it 'indicates the default jp2 filename' do
24
- expect(ai.jp2_filename).to eq '/path/to/a/file_with_no_extension.jp2'
25
- end
26
- end
27
- end
28
-
29
- describe '#dpg_jp2_filename' do
30
- context 'with a dpg tiff file' do
31
- let(:input_path) { TEST_DPG_TIF_INPUT_FILE }
32
-
33
- it 'indicates the default DPG jp2 filename' do
34
- expect(ai.dpg_jp2_filename).to eq TEST_DPG_TIF_INPUT_FILE.gsub('.tif', '.jp2').gsub('_00_', '_05_')
35
- end
36
- end
37
-
38
- context 'with a file with no extension' do
39
- let(:input_path) { '/path/to/a/file_with_no_00_extension' }
40
-
41
- it 'indicates the default jp2 filename' do
42
- expect(ai.dpg_jp2_filename).to eq '/path/to/a/file_with_no_05_extension.jp2'
22
+ expect(assembly_image.jp2_filename).to eq '/path/to/a/file_with_no_extension.jp2'
43
23
  end
44
24
  end
45
25
  end
@@ -49,178 +29,243 @@ RSpec.describe Assembly::Image do
49
29
  let(:input_path) { '' }
50
30
 
51
31
  it 'does not run if no input file is passed in' do
52
- expect { ai.create_jp2 }.to raise_error
32
+ expect { assembly_image.create_jp2 }.to raise_error(RuntimeError)
53
33
  end
54
34
  end
55
35
 
56
36
  context 'when given an uncompressed compressed RGB tif with more than 4GB of image data', skip: 'This test will create a 4GB test image and a 4GB temporary image, so skipping by default.' do
37
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'rgb.tif') }
38
+
57
39
  before do
58
- generate_test_image(TEST_TIF_INPUT_FILE, compress: 'none', width: '37838', height: '37838')
40
+ generate_test_image(input_path, compress: 'none', width: '37838', height: '37838')
59
41
  end
60
42
 
61
43
  it 'creates the jp2 with a temp file' do
62
- expect(File).to exist TEST_TIF_INPUT_FILE
63
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
64
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
65
- expect(ai.tmp_path).not_to be_nil
44
+ expect(File).to exist input_path
45
+ expect(File).not_to exist jp2_output_file
46
+ result = assembly_image.create_jp2(output: jp2_output_file)
47
+ expect(assembly_image.tmp_path).not_to be_nil
66
48
  expect(result).to be_a_kind_of described_class
67
- expect(result.path).to eq TEST_JP2_OUTPUT_FILE
68
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
49
+ expect(result.path).to eq jp2_output_file
50
+ expect(jp2_output_file).to be_a_jp2
69
51
  expect(result.exif.colorspace).to eq 'sRGB'
70
- jp2 = described_class.new(TEST_JP2_OUTPUT_FILE)
71
- expect(jp2.height).to eq 37_838
72
- expect(jp2.width).to eq 37_838
52
+ expect(result.height).to eq 37_838
53
+ expect(result.width).to eq 37_838
73
54
  end
74
55
  end
75
56
 
76
57
  context 'when given an LZW compressed RGB tif with more than 4GB of image data', skip: 'This test will create a 4GB temporary image, so skipping by default.' do
58
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'lzw.tif') }
59
+
77
60
  before do
78
- generate_test_image(TEST_TIF_INPUT_FILE, compress: 'lzw', width: '37838', height: '37838')
61
+ generate_test_image(input_path, compress: 'lzw', width: '37838', height: '37838')
79
62
  end
80
63
 
81
64
  it 'creates the jp2 with a temp file' do
82
- expect(File).to exist TEST_TIF_INPUT_FILE
83
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
84
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
85
- expect(ai.tmp_path).not_to be_nil
65
+ expect(File).to exist input_path
66
+ expect(File).not_to exist jp2_output_file
67
+ expect(assembly_image.exif.samplesperpixel).to be 3
68
+ expect(assembly_image.exif.bitspersample).to eql '8 8 8'
69
+ expect(assembly_image).to be_a_valid_image
70
+ expect(assembly_image).to be_jp2abl
71
+ result = assembly_image.create_jp2(output: jp2_output_file)
72
+ expect(assembly_image.tmp_path).not_to be_nil
86
73
  expect(result).to be_a_kind_of described_class
87
- expect(result.path).to eq TEST_JP2_OUTPUT_FILE
88
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
74
+ expect(result.path).to eq jp2_output_file
75
+ expect(jp2_output_file).to be_a_jp2
89
76
  expect(result.exif.colorspace).to eq 'sRGB'
90
- jp2 = described_class.new(TEST_JP2_OUTPUT_FILE)
91
- expect(jp2.height).to eq 37_838
92
- expect(jp2.width).to eq 37_838
77
+ expect(result.height).to eq 37_838
78
+ expect(result.width).to eq 37_838
93
79
  end
94
80
  end
95
81
 
96
82
  context 'when given a bitonal tif' do
83
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'bitonal.tif') }
84
+
97
85
  before do
98
- # Need to force group4 compression to get ImageMagick to create bitonal tiff
99
- generate_test_image(TEST_TIF_INPUT_FILE, image_type: 'Bilevel', compress: 'group4')
86
+ generate_test_image(input_path, color: 'bin', bands: 1, depth: 1)
100
87
  end
101
88
 
102
- it 'creates grayscale jp2' do
103
- expect(File).to exist TEST_TIF_INPUT_FILE
104
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
105
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
106
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
89
+ it 'creates valid jp2' do
90
+ expect(File).to exist input_path
91
+ expect(File).not_to exist jp2_output_file
92
+ expect(assembly_image.exif.samplesperpixel).to be 1
93
+ expect(assembly_image.exif.bitspersample).to be 1
94
+ expect(assembly_image).not_to have_color_profile
95
+ result = assembly_image.create_jp2(output: jp2_output_file)
96
+ expect(result).to be_a_kind_of described_class
97
+ expect(result.path).to eq jp2_output_file
98
+ expect(jp2_output_file).to be_a_jp2
107
99
  expect(result.exif.colorspace).to eq 'Grayscale'
108
100
  end
109
101
  end
110
102
 
111
103
  context 'when given a color tif but bitonal image data (1 channels and 1 bits per pixel)' do
104
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'color.tif') }
105
+
112
106
  before do
113
- generate_test_image(TEST_TIF_INPUT_FILE, color: 'Bilevel', image_type: 'TrueColor', profile: '')
107
+ generate_test_image(input_path, color: 'bin', bands: 3)
114
108
  end
115
109
 
116
110
  it 'creates color jp2' do
117
- expect(File).to exist TEST_TIF_INPUT_FILE
118
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
119
- expect(ai).not_to have_color_profile
120
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
121
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
111
+ expect(File).to exist input_path
112
+ expect(File).not_to exist jp2_output_file
113
+ expect(assembly_image).not_to have_color_profile
114
+ expect(assembly_image.exif.samplesperpixel).to be 3
115
+ expect(assembly_image.exif.bitspersample).to eql '8 8 8'
116
+ expect(assembly_image).to be_a_valid_image
117
+ expect(assembly_image).to be_jp2able
118
+ result = assembly_image.create_jp2(output: jp2_output_file)
119
+ expect(result).to be_a_kind_of described_class
120
+ expect(result.path).to eq jp2_output_file
121
+ expect(jp2_output_file).to be_a_jp2
122
122
  expect(result.exif.colorspace).to eq 'sRGB'
123
123
  end
124
124
  end
125
125
 
126
126
  context 'when given a graycale tif but with bitonal image data (1 channel and 1 bits per pixel)' do
127
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'gray.tif') }
128
+
127
129
  before do
128
- generate_test_image(TEST_TIF_INPUT_FILE, color: 'Bilevel', image_type: 'Grayscale', profile: '')
130
+ generate_test_image(input_path, color: 'grey', bands: 1)
129
131
  end
130
132
 
131
133
  it 'creates grayscale jp2' do
132
- expect(File).to exist TEST_TIF_INPUT_FILE
133
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
134
- expect(ai).not_to have_color_profile
135
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
136
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
134
+ expect(File).to exist input_path
135
+ expect(File).not_to exist jp2_output_file
136
+ expect(assembly_image).not_to have_color_profile
137
+ expect(assembly_image.exif.samplesperpixel).to be 1
138
+ expect(assembly_image.exif.bitspersample).to be 8
139
+ expect(assembly_image).to be_a_valid_image
140
+ expect(assembly_image).to be_jp2able
141
+ result = assembly_image.create_jp2(output: jp2_output_file)
142
+ expect(jp2_output_file).to be_a_jp2
143
+ expect(result).to be_a_kind_of described_class
144
+ expect(result.path).to eq jp2_output_file
137
145
  expect(result.exif.colorspace).to eq 'Grayscale'
138
146
  end
139
147
  end
140
148
 
141
149
  context 'when given a color tif but with greyscale image data (1 channel and 8 bits per pixel)' do
150
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'color_gray.tif') }
151
+
142
152
  before do
143
- generate_test_image(TEST_TIF_INPUT_FILE, color: 'Grayscale', image_type: 'TrueColor', profile: '')
153
+ generate_test_image(input_path, color: 'grey')
144
154
  end
145
155
 
146
156
  it 'creates color jp2' do
147
- expect(File).to exist TEST_TIF_INPUT_FILE
148
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
149
- expect(ai).not_to have_color_profile
150
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
151
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
157
+ expect(File).to exist input_path
158
+ expect(File).not_to exist jp2_output_file
159
+ expect(assembly_image.exif.samplesperpixel).to be 3
160
+ expect(assembly_image.exif.bitspersample).to eql '8 8 8'
161
+ expect(assembly_image).to be_a_valid_image
162
+ expect(assembly_image).to be_jp2able
163
+ expect(assembly_image).not_to have_color_profile
164
+ result = assembly_image.create_jp2(output: jp2_output_file)
165
+ expect(result).to be_a_kind_of described_class
166
+ expect(result.path).to eq jp2_output_file
167
+ expect(jp2_output_file).to be_a_jp2
152
168
  expect(result.exif.colorspace).to eq 'sRGB'
153
169
  end
154
170
  end
155
171
 
172
+ context 'when given a cmyk tif' do
173
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'cmky.tif') }
174
+
175
+ before do
176
+ generate_test_image(input_path, color: 'cmyk', cg_type: 'cmyk', profile: 'cmyk', bands: 4)
177
+ end
178
+
179
+ it 'creates an srgb jp2', skip: 'Need to verify the color space is correct in jp2' do
180
+ expect(File).to exist input_path
181
+ expect(File).not_to exist jp2_output_file
182
+ expect(assembly_image.exif.samplesperpixel).to be 4
183
+ expect(assembly_image.exif.bitspersample).to eql '8 8 8 8'
184
+ expect(assembly_image).to be_a_valid_image
185
+ expect(assembly_image).to be_jp2able
186
+ expect(assembly_image).to have_color_profile
187
+ result = assembly_image.create_jp2(output: jp2_output_file)
188
+ expect(result).to be_a_kind_of described_class
189
+ expect(result.path).to eq jp2_output_file
190
+ expect(jp2_output_file).to be_a_jp2
191
+ # note, we verify the CMYK has been converted to an SRGB JP2 correctly by using ruby-vips instead of exif, since exif does not correctly
192
+ # identify the color space...note: this line current does not work in circleci, potentially due to libvips version differences
193
+ expect(Vips::Image.new_from_file(jp2_output_file).get_value('interpretation')).to eq :srgb
194
+ end
195
+ end
196
+
156
197
  context 'when the source image has no profile' do
198
+ let(:input_path) { File.join(TEST_INPUT_DIR, 'no_profile.tif') }
199
+
157
200
  before do
158
- generate_test_image(TEST_TIF_INPUT_FILE, profile: '') # generate a test input with no profile
201
+ generate_test_image(input_path)
159
202
  end
160
203
 
161
204
  it 'creates a jp2' do
162
- expect(File).to exist TEST_TIF_INPUT_FILE
163
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
164
- expect(ai).not_to have_color_profile
165
- expect(ai).to be_a_valid_image
166
- expect(ai).to be_jp2able
167
- ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
168
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
205
+ expect(File).to exist input_path
206
+ expect(File).not_to exist jp2_output_file
207
+ expect(assembly_image.exif.samplesperpixel).to be 3
208
+ expect(assembly_image.exif.bitspersample).to eql '8 8 8'
209
+ expect(assembly_image).not_to have_color_profile
210
+ expect(assembly_image).to be_a_valid_image
211
+ expect(assembly_image).to be_jp2able
212
+ assembly_image.create_jp2(output: jp2_output_file)
213
+ expect(jp2_output_file).to be_a_jp2
169
214
  end
170
215
  end
171
216
 
172
217
  context "when the output file exists and you don't allow overwriting" do
173
218
  before do
174
- generate_test_image(TEST_TIF_INPUT_FILE)
175
- generate_test_image(TEST_JP2_OUTPUT_FILE)
219
+ generate_test_image(input_path)
220
+ FileUtils.touch(jp2_output_file) # just need a file with this name, don't care what
176
221
  end
177
222
 
178
223
  it 'does not run' do
179
- expect(File).to exist TEST_TIF_INPUT_FILE
180
- expect(File).to exist TEST_JP2_OUTPUT_FILE
181
- expect { ai.create_jp2(output: TEST_JP2_OUTPUT_FILE) }.to raise_error(SecurityError)
224
+ expect(File).to exist input_path
225
+ expect(File).to exist jp2_output_file
226
+ expect { assembly_image.create_jp2(output: jp2_output_file) }.to raise_error(SecurityError)
182
227
  end
183
228
  end
184
229
 
185
230
  context 'when given a test tiff' do
186
231
  before do
187
- generate_test_image(TEST_TIF_INPUT_FILE)
232
+ generate_test_image(input_path)
188
233
  end
189
234
 
190
235
  it 'gets the correct image height and width' do
191
- expect(ai.height).to eq 100
192
- expect(ai.width).to eq 100
236
+ expect(assembly_image.height).to eq 36
237
+ expect(assembly_image.width).to eq 43
193
238
  end
194
239
  end
195
240
 
196
241
  context 'when the input file is a jp2' do
197
242
  before do
198
- generate_test_image(TEST_TIF_INPUT_FILE, profile: '') # generate a test input with no profile
243
+ generate_test_image(input_path)
199
244
  end
200
245
 
201
246
  it 'does not run' do
202
- expect(File).to exist TEST_TIF_INPUT_FILE
203
- expect(File).not_to exist TEST_JP2_OUTPUT_FILE
204
- expect(ai).not_to have_color_profile
205
- expect(ai).to be_a_valid_image
206
- expect(ai).to be_jp2able
207
- ai.create_jp2(output: TEST_JP2_OUTPUT_FILE)
208
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
209
- jp2_file = described_class.new(TEST_JP2_OUTPUT_FILE)
247
+ expect(File).to exist input_path
248
+ expect(File).not_to exist jp2_output_file
249
+ expect(assembly_image).not_to have_color_profile
250
+ expect(assembly_image).to be_a_valid_image
251
+ expect(assembly_image).to be_jp2able
252
+ assembly_image.create_jp2(output: jp2_output_file)
253
+ expect(jp2_output_file).to be_a_jp2
254
+ jp2_file = described_class.new(jp2_output_file)
210
255
  expect(jp2_file).to be_valid_image
211
256
  expect(jp2_file).not_to be_jp2able
212
- expect { jp2_file.create_jp2 }.to raise_error
257
+ expect { jp2_file.create_jp2 }.to raise_error(RuntimeError)
213
258
  end
214
259
  end
215
260
 
216
261
  context 'when you specify a bogus output profile' do
217
262
  before do
218
- generate_test_image(TEST_TIF_INPUT_FILE)
263
+ generate_test_image(input_path)
219
264
  end
220
265
 
221
266
  it 'runs, because this is not currently an option' do
222
- expect(File).to exist TEST_TIF_INPUT_FILE
223
- result = ai.create_jp2(output_profile: 'bogusness')
267
+ expect(File).to exist input_path
268
+ result = assembly_image.create_jp2(output_profile: 'bogusness')
224
269
  expect(result).to be_a_kind_of described_class
225
270
  expect(result.path).to eq TEST_JP2_INPUT_FILE
226
271
  expect(TEST_JP2_INPUT_FILE).to be_a_jp2
@@ -239,19 +284,19 @@ RSpec.describe Assembly::Image do
239
284
  bogus_folder = '/crapsticks'
240
285
  expect(File).to exist TEST_JPEG_INPUT_FILE
241
286
  expect(File).not_to exist bogus_folder
242
- expect { ai.create_jp2(tmp_folder: bogus_folder) }.to raise_error
287
+ expect { assembly_image.create_jp2(tmp_folder: bogus_folder) }.to raise_error(RuntimeError)
243
288
  end
244
289
  end
245
290
 
246
291
  context 'when no output file is specified' do
247
292
  before do
248
- generate_test_image(TEST_TIF_INPUT_FILE)
293
+ generate_test_image(input_path)
249
294
  end
250
295
 
251
296
  it 'creates a jp2 of the same filename and in the same location as the input and cleans up the tmp file' do
252
- expect(File).to exist TEST_TIF_INPUT_FILE
297
+ expect(File).to exist input_path
253
298
  expect(File.exist?(TEST_JP2_INPUT_FILE)).to be false
254
- result = ai.create_jp2
299
+ result = assembly_image.create_jp2
255
300
  expect(result).to be_a_kind_of described_class
256
301
  expect(result.path).to eq TEST_JP2_INPUT_FILE
257
302
  expect(TEST_JP2_INPUT_FILE).to be_a_jp2
@@ -261,17 +306,17 @@ RSpec.describe Assembly::Image do
261
306
 
262
307
  context 'when the output file exists and you allow overwriting' do
263
308
  before do
264
- generate_test_image(TEST_TIF_INPUT_FILE)
265
- generate_test_image(TEST_JP2_OUTPUT_FILE)
309
+ generate_test_image(input_path)
310
+ FileUtils.touch(jp2_output_file) # just need a file with this name, don't care what
266
311
  end
267
312
 
268
313
  it 'recreates jp2' do
269
- expect(File).to exist TEST_TIF_INPUT_FILE
270
- expect(File).to exist TEST_JP2_OUTPUT_FILE
271
- result = ai.create_jp2(output: TEST_JP2_OUTPUT_FILE, overwrite: true)
314
+ expect(File).to exist input_path
315
+ expect(File).to exist jp2_output_file
316
+ result = assembly_image.create_jp2(output: jp2_output_file, overwrite: true)
272
317
  expect(result).to be_a_kind_of described_class
273
- expect(result.path).to eq TEST_JP2_OUTPUT_FILE
274
- expect(TEST_JP2_OUTPUT_FILE).to be_a_jp2
318
+ expect(result.path).to eq jp2_output_file
319
+ expect(jp2_output_file).to be_a_jp2
275
320
  expect(result.exif.colorspace).to eq 'sRGB'
276
321
  end
277
322
  end
data/spec/images_spec.rb CHANGED
@@ -3,45 +3,45 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Assembly::Images do
6
- after do
7
- # after each test, empty out the input and output test directories
8
- remove_files(TEST_INPUT_DIR)
9
- remove_files(TEST_OUTPUT_DIR)
6
+ before { cleanup }
7
+
8
+ describe '#batch_generate_jp2' do
9
+ it 'does not run if no input folder is passed in' do
10
+ expect{ described_class.batch_generate_jp2('') }.to raise_error(RuntimeError)
11
+ end
12
+
13
+ it 'does not run if a non-existent input folder is passed in' do
14
+ expect{ described_class.batch_generate_jp2('/junk/path') }.to raise_error(RuntimeError)
15
+ end
16
+
17
+ it 'runs and batch produces jp2s from input tiffs' do
18
+ ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif"), profile: 'AdobeRGB1998') }
19
+ described_class.batch_generate_jp2(TEST_INPUT_DIR, output: TEST_OUTPUT_DIR)
20
+ expect(File.directory?(TEST_OUTPUT_DIR)).to be true
21
+ ['test1', 'test2', 'test3'].each { |image| expect(File.join(TEST_OUTPUT_DIR, "#{image}.jp2")).to be_a_jp2 }
22
+ end
10
23
  end
11
24
 
12
- it 'does not run if no input folder is passed in' do
13
- expect{ described_class.batch_generate_jp2('') }.to raise_error
14
- end
15
-
16
- it 'does not run if a non-existent input folder is passed in' do
17
- expect{ described_class.batch_generate_jp2('/junk/path') }.to raise_error
18
- end
19
-
20
- it 'runs and batch produces jp2s from input tiffs' do
21
- ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif")) }
22
- described_class.batch_generate_jp2(TEST_INPUT_DIR, output: TEST_OUTPUT_DIR)
23
- expect(File.directory?(TEST_OUTPUT_DIR)).to be true
24
- ['test1', 'test2', 'test3'].each { |image| expect(File.join(TEST_OUTPUT_DIR, "#{image}.jp2")).to be_a_jp2 }
25
- end
26
-
27
- it 'runs and batch add color profile descriptions input tiffs with no color profile descriptions' do
28
- ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif"), profile: '') }
29
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to be_nil }
30
- described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998')
31
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'Adobe RGB (1998)' }
32
- end
33
-
34
- it 'runs and batch add color profile descriptions input tiffs, forcing over existing color profile descriptions' do
35
- ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif")) }
36
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
37
- described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998', force: true) # force overwrite
38
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'Adobe RGB (1998)' }
39
- end
40
-
41
- it 'runs and batch add color profile descriptions input tiffs, not overwriting existing color profile descriptions' do
42
- ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif")) }
43
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
44
- described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998') # do not force overwrite
45
- ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
25
+ describe '#batch_add_exif_profile_descr' do
26
+ it 'runs and batch adds color profile descriptions to input tiffs that had no color profile descriptions' do
27
+ ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif")) }
28
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to be_nil }
29
+ described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998')
30
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'Adobe RGB (1998)' }
31
+ end
32
+
33
+ it 'runs and batch adds color profile descriptions to input tiffs, forcing over existing color profile descriptions' do
34
+ ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif"), profile: 'sRGBIEC6196621') }
35
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
36
+ described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998', force: true) # force overwrite
37
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'Adobe RGB (1998)' }
38
+ end
39
+
40
+ it 'runs and batch adds color profile descriptions to input tiffs, not overwriting existing color profile descriptions' do
41
+ ['test1', 'test2', 'test3'].each { |image| generate_test_image(File.join(TEST_INPUT_DIR, "#{image}.tif"), profile: 'sRGBIEC6196621') }
42
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
43
+ described_class.batch_add_exif_profile_descr(TEST_INPUT_DIR, 'Adobe RGB 1998') # do not force overwrite
44
+ ['test1', 'test2', 'test3'].each { |image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR, "#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1' }
45
+ end
46
46
  end
47
47
  end