assembly-objectfile 1.5.3 → 1.5.4

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.
data/README.rdoc CHANGED
@@ -58,6 +58,7 @@ content type specific operations (such as jp2 generation).
58
58
  - 1.5.1 Pin mini_exiftool to 1.x and Nokogiri to 1.5.x branch for Ruby 1.8.7, added image/png and application/zip
59
59
  - 1.5.2 Fix for Rails 4 and support for 'rake console'
60
60
  - 1.5.3 More gemfile updates
61
+ - 1.5.4 jp2able? method now returns true even if profile description is missing; add new method which does a check for existing color profile in an image
61
62
 
62
63
  ==Usage
63
64
 
@@ -194,7 +194,7 @@ module Assembly
194
194
  object_type == :image
195
195
  end
196
196
 
197
- # Examines the input image for validity. Used to determine if image is a valid and useful image. If image is not a jp2, also checks for a valid profile.
197
+ # Examines the input image for validity. Used to determine if image is a valid and useful image. If image is not a jp2, also checks if it is jp2able?
198
198
  #
199
199
  # @return [boolean] true if image is valid, false if not.
200
200
  #
@@ -210,6 +210,17 @@ module Assembly
210
210
 
211
211
  end
212
212
 
213
+ # Examines the input image for a color profile.
214
+ #
215
+ # @return [boolean] true if image has a color profile, false if not.
216
+ #
217
+ # Example:
218
+ # source_img=Assembly::ObjectFile.new('/input/path_to_file.tif')
219
+ # puts source_img.has_color_profile? # gives true
220
+ def has_color_profile?
221
+ exif.nil? ? false : !exif['profiledescription'].nil? # check for existence of profile description
222
+ end
223
+
213
224
  # Examines the input image for validity to create a jp2. Same as valid_image? but also confirms the existence of a profile description and further restricts mimetypes.
214
225
  # It is used by the assembly robots to decide if a jp2 will be created and is also called before you create a jp2 using assembly-image.
215
226
  # @return [boolean] true if image should have a jp2 created, false if not.
@@ -222,7 +233,6 @@ module Assembly
222
233
  result=false
223
234
  unless exif.nil?
224
235
  result=(Assembly::VALID_IMAGE_MIMETYPES.include?(mimetype)) # check for allowed image mimetypes that can be converted to jp2
225
- result=(exif['profiledescription'] != nil) # check for existence of profile description
226
236
  end
227
237
  return result
228
238
 
@@ -3,7 +3,7 @@ module Assembly
3
3
 
4
4
  class ObjectFile
5
5
  # Project version number
6
- VERSION = "1.5.3"
6
+ VERSION = "1.5.4"
7
7
  end
8
8
 
9
9
  end
@@ -53,13 +53,34 @@ describe Assembly::ObjectFile do
53
53
  @ai.dpg_folder.should == "05"
54
54
  end
55
55
 
56
- it "should tell us that a jp2 file not jp2able and is not valid since it has no profile" do
56
+ it "should tell us that a jp2 file is jp2able but has no color profile" do
57
57
  File.exists?(TEST_JP2_INPUT_FILE).should be true
58
58
  @ai = Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)
59
59
  @ai.image?.should == true
60
60
  @ai.object_type.should == :image
61
61
  @ai.valid_image?.should == true
62
- @ai.jp2able?.should == false
62
+ @ai.jp2able?.should == true
63
+ @ai.has_color_profile?.should == false
64
+ end
65
+
66
+ it "should tell us that a tiff file is jp2able and has a color profile" do
67
+ File.exists?(TEST_RES1_TIF1).should be true
68
+ @ai = Assembly::ObjectFile.new(TEST_RES1_TIF1)
69
+ @ai.image?.should == true
70
+ @ai.object_type.should == :image
71
+ @ai.valid_image?.should == true
72
+ @ai.jp2able?.should == true
73
+ @ai.has_color_profile?.should == true
74
+ end
75
+
76
+ it "should tell us that a tiff file is not jp2able and is not valid since it has no profile" do
77
+ File.exists?(TEST_TIFF_NO_COLOR_FILE).should be true
78
+ @ai = Assembly::ObjectFile.new(TEST_TIFF_NO_COLOR_FILE)
79
+ @ai.image?.should == true
80
+ @ai.object_type.should == :image
81
+ @ai.valid_image?.should == true
82
+ @ai.jp2able?.should == true
83
+ @ai.has_color_profile?.should == false
63
84
  end
64
85
 
65
86
  it "should compute checksums for an image file" do
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,8 @@ TEST_DPG_SPECIAL_PDF1=File.join(TEST_INPUT_DIR,'oo000oo0001','oo000oo0001_book.p
22
22
  TEST_DPG_SPECIAL_PDF2=File.join(TEST_INPUT_DIR,'oo000oo0001','31','oo000oo0001_31_001.pdf')
23
23
  TEST_DPG_SPECIAL_TIF=File.join(TEST_INPUT_DIR,'oo000oo0001','50','oo000oo0001_50_001.tif')
24
24
 
25
+ TEST_TIFF_NO_COLOR_FILE=File.join(TEST_INPUT_DIR,'test_no_color_profile.tif')
26
+
25
27
  TEST_RES1_TIF1=File.join(TEST_INPUT_DIR,'res1_image1.tif')
26
28
  TEST_RES1_JP1=File.join(TEST_INPUT_DIR,'res1_image1.jp2')
27
29
  TEST_RES1_TIF2=File.join(TEST_INPUT_DIR,'res1_image2.tif')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assembly-objectfile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 3
10
- version: 1.5.3
9
+ - 4
10
+ version: 1.5.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Mangiafico
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2013-08-23 00:00:00 Z
21
+ date: 2013-08-29 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -219,6 +219,7 @@ files:
219
219
  - spec/test_data/input/test.tif
220
220
  - spec/test_data/input/test2.jp2
221
221
  - spec/test_data/input/test2.tif
222
+ - spec/test_data/input/test_no_color_profile.tif
222
223
  homepage: ""
223
224
  licenses: []
224
225
 
@@ -290,4 +291,5 @@ test_files:
290
291
  - spec/test_data/input/test.tif
291
292
  - spec/test_data/input/test2.jp2
292
293
  - spec/test_data/input/test2.tif
294
+ - spec/test_data/input/test_no_color_profile.tif
293
295
  has_rdoc: