assembly-image 1.6.8 → 1.6.9

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.
@@ -2,40 +2,40 @@ require 'spec_helper'
2
2
 
3
3
  describe Assembly::Images do
4
4
 
5
- it "should not run if no input folder is passed in" do
6
- lambda{Assembly::Images.batch_generate_jp2('')}.should raise_error
5
+ it 'should not run if no input folder is passed in' do
6
+ expect{Assembly::Images.batch_generate_jp2('')}.to raise_error
7
7
  end
8
8
 
9
- it "should not run if a non-existent input folder is passed in" do
10
- lambda{Assembly::Images.batch_generate_jp2('/junk/path')}.should raise_error
9
+ it 'should not run if a non-existent input folder is passed in' do
10
+ expect{Assembly::Images.batch_generate_jp2('/junk/path')}.to raise_error
11
11
  end
12
12
 
13
- it "should run and batch produe jp2s from input tiffs" do
13
+ it 'should run and batch produe jp2s from input tiffs' do
14
14
  ['test1','test2','test3'].each {|image| generate_test_image(File.join(TEST_INPUT_DIR,"#{image}.tif")) }
15
15
  Assembly::Images.batch_generate_jp2(TEST_INPUT_DIR,:output=>TEST_OUTPUT_DIR)
16
- File.directory?(TEST_OUTPUT_DIR).should be true
17
- ['test1','test2','test3'].each {|image| is_jp2?(File.join(TEST_OUTPUT_DIR,"#{image}.jp2")).should be_true }
16
+ expect(File.directory?(TEST_OUTPUT_DIR)).to be true
17
+ ['test1','test2','test3'].each {|image| expect(File.join(TEST_OUTPUT_DIR,"#{image}.jp2")).to be_a_jp2 }
18
18
  end
19
19
 
20
- it "should run and batch add color profile descriptions input tiffs with no color profile descriptions" do
20
+ it 'should run and batch add color profile descriptions input tiffs with no color profile descriptions' do
21
21
  ['test1','test2','test3'].each {|image| generate_test_image(File.join(TEST_INPUT_DIR,"#{image}.tif"),:profile=>'') }
22
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should be nil}
22
+ ['test1','test2','test3'].each {|image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription).to be nil}
23
23
  Assembly::Images.batch_add_exif_profile_description(TEST_INPUT_DIR,'Adobe RGB 1998')
24
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should == 'Adobe RGB (1998)'}
24
+ ['test1','test2','test3'].each {|image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription).to eq 'Adobe RGB (1998)'}
25
25
  end
26
-
27
- it "should run and batch add color profile descriptions input tiffs, forcing over existing color profile descriptions" do
26
+
27
+ it 'should run and batch add color profile descriptions input tiffs, forcing over existing color profile descriptions' do
28
28
  ['test1','test2','test3'].each {|image| generate_test_image(File.join(TEST_INPUT_DIR,"#{image}.tif")) }
29
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should == 'sRGB IEC61966-2.1'}
29
+ ['test1','test2','test3'].each {|image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1'}
30
30
  Assembly::Images.batch_add_exif_profile_description(TEST_INPUT_DIR,'Adobe RGB 1998',:force=>true) # force overwrite
31
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should == '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
32
  end
33
33
 
34
- it "should run and batch add color profile descriptions input tiffs, not overwriting existing color profile descriptions" do
34
+ it 'should run and batch add color profile descriptions input tiffs, not overwriting existing color profile descriptions' do
35
35
  ['test1','test2','test3'].each {|image| generate_test_image(File.join(TEST_INPUT_DIR,"#{image}.tif")) }
36
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should == 'sRGB IEC61966-2.1'}
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
37
  Assembly::Images.batch_add_exif_profile_description(TEST_INPUT_DIR,'Adobe RGB 1998') # do not force overwrite
38
- ['test1','test2','test3'].each {|image| Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription.should == 'sRGB IEC61966-2.1'}
38
+ ['test1','test2','test3'].each {|image| expect(Assembly::Image.new(File.join(TEST_INPUT_DIR,"#{image}.tif")).exif.profiledescription).to eq 'sRGB IEC61966-2.1'}
39
39
  end
40
40
 
41
41
 
@@ -8,7 +8,7 @@ TEST_DPG_TIF_INPUT_FILE = File.join(TEST_INPUT_DIR,'oo000oo0001_00_01.tif')
8
8
  TEST_JPEG_INPUT_FILE = File.join(TEST_INPUT_DIR,'test.jpg')
9
9
  TEST_JP2_INPUT_FILE = File.join(TEST_INPUT_DIR,'test.jp2')
10
10
  TEST_JP2_OUTPUT_FILE = File.join(TEST_OUTPUT_DIR,'test.jp2')
11
- TEST_DRUID = "nx288wh8889"
11
+ TEST_DRUID = 'nx288wh8889'
12
12
 
13
13
  # generate a sample image file with a specified profile
14
14
  def generate_test_image(file,params={})
@@ -16,22 +16,27 @@ def generate_test_image(file,params={})
16
16
  profile=params[:profile] || 'sRGBIEC6196621'
17
17
  image_type=params[:image_type]
18
18
  create_command="convert -size 100x100 xc:#{color} "
19
- create_command += " -profile " + File.join(Assembly::PATH_TO_IMAGE_GEM,'profiles',profile+'.icc') + " " unless profile == ''
19
+ create_command += ' -profile ' + File.join(Assembly::PATH_TO_IMAGE_GEM,'profiles',profile+'.icc') + ' ' unless profile == ''
20
20
  create_command += " -type #{image_type} " if image_type
21
21
  create_command += file
22
- system(create_command)
22
+ create_command += ' 2>&1'
23
+ output = `#{create_command}`
24
+ unless $?.success?
25
+ raise "Failed to create test image #{file} (#{params}): \n#{output}"
26
+ end
23
27
  end
24
28
 
25
29
  def remove_files(dir)
26
30
  Dir.foreach(dir) {|f| fn = File.join(dir, f); File.delete(fn) if !File.directory?(fn) && File.basename(fn) != '.empty'}
27
31
  end
28
32
 
29
- # check the existence and mime_type of the supplied file and confirm if it's jp2
30
- def is_jp2?(file)
31
- if File.exists?(file)
32
- exif = MiniExiftool.new file
33
- return exif['mimetype'] == 'image/jp2'
34
- else
35
- false
33
+ RSpec::Matchers.define :be_a_jp2 do
34
+ match do |actual|
35
+ if File.exists?(actual)
36
+ exif = MiniExiftool.new actual
37
+ exif['mimetype'] == 'image/jp2'
38
+ else
39
+ false
40
+ end
36
41
  end
37
- end
42
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assembly-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
@@ -9,137 +9,117 @@ authors:
9
9
  - Monty Hindman
10
10
  - Tony Calavano
11
11
  autorequire:
12
- bindir: bin
12
+ bindir: exe
13
13
  cert_chain: []
14
- date: 2015-01-22 00:00:00.000000000 Z
14
+ date: 2016-11-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: uuidtools
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ! '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: assembly-objectfile
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ! '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.6.4
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ! '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.6.4
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: mini_exiftool
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '1.6'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ~>
56
- - !ruby/object:Gem::Version
57
- version: '1.6'
58
- - !ruby/object:Gem::Dependency
59
- name: activesupport
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ! '>'
51
+ - - "<"
63
52
  - !ruby/object:Gem::Version
64
53
  version: '3'
65
54
  type: :runtime
66
55
  prerelease: false
67
56
  version_requirements: !ruby/object:Gem::Requirement
68
57
  requirements:
69
- - - ! '>'
70
- - !ruby/object:Gem::Version
71
- version: '3'
72
- - !ruby/object:Gem::Dependency
73
- name: nokogiri
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ! '>='
58
+ - - ">="
77
59
  - !ruby/object:Gem::Version
78
- version: '0'
79
- type: :runtime
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ! '>='
60
+ version: '1.6'
61
+ - - "<"
84
62
  - !ruby/object:Gem::Version
85
- version: '0'
63
+ version: '3'
86
64
  - !ruby/object:Gem::Dependency
87
65
  name: rspec
88
66
  requirement: !ruby/object:Gem::Requirement
89
67
  requirements:
90
- - - ~>
68
+ - - "~>"
91
69
  - !ruby/object:Gem::Version
92
- version: '2.6'
70
+ version: '3.0'
93
71
  type: :development
94
72
  prerelease: false
95
73
  version_requirements: !ruby/object:Gem::Requirement
96
74
  requirements:
97
- - - ~>
75
+ - - "~>"
98
76
  - !ruby/object:Gem::Version
99
- version: '2.6'
77
+ version: '3.0'
100
78
  - !ruby/object:Gem::Dependency
101
- name: lyberteam-gems-devel
79
+ name: yard
102
80
  requirement: !ruby/object:Gem::Requirement
103
81
  requirements:
104
- - - ! '>'
82
+ - - ">="
105
83
  - !ruby/object:Gem::Version
106
- version: 1.0.0
84
+ version: '0'
107
85
  type: :development
108
86
  prerelease: false
109
87
  version_requirements: !ruby/object:Gem::Requirement
110
88
  requirements:
111
- - - ! '>'
89
+ - - ">="
112
90
  - !ruby/object:Gem::Version
113
- version: 1.0.0
91
+ version: '0'
114
92
  - !ruby/object:Gem::Dependency
115
- name: yard
93
+ name: rake
116
94
  requirement: !ruby/object:Gem::Requirement
117
95
  requirements:
118
- - - ! '>='
96
+ - - ">="
119
97
  - !ruby/object:Gem::Version
120
98
  version: '0'
121
99
  type: :development
122
100
  prerelease: false
123
101
  version_requirements: !ruby/object:Gem::Requirement
124
102
  requirements:
125
- - - ! '>='
103
+ - - ">="
126
104
  - !ruby/object:Gem::Version
127
105
  version: '0'
128
106
  description: Contains classes to create derivative image files and perform other image
129
107
  operations
130
108
  email:
131
109
  - pmangiafico@stanford.edu
132
- executables:
133
- - console
134
- - run_all_tests
110
+ executables: []
135
111
  extensions: []
136
112
  extra_rdoc_files: []
137
113
  files:
138
- - .gitignore
139
- - .rvmrc.example
114
+ - ".gitignore"
115
+ - ".rspec"
116
+ - ".rubocop.yml"
117
+ - ".rubocop_todo.yml"
118
+ - ".rvmrc.example"
119
+ - ".travis.yml"
140
120
  - Gemfile
141
121
  - LICENSE
142
- - README.rdoc
122
+ - README.md
143
123
  - Rakefile
144
124
  - assembly-image.gemspec
145
125
  - bin/console
@@ -166,17 +146,17 @@ require_paths:
166
146
  - lib
167
147
  required_ruby_version: !ruby/object:Gem::Requirement
168
148
  requirements:
169
- - - ! '>='
149
+ - - ">="
170
150
  - !ruby/object:Gem::Version
171
151
  version: '0'
172
152
  required_rubygems_version: !ruby/object:Gem::Requirement
173
153
  requirements:
174
- - - ! '>='
154
+ - - ">="
175
155
  - !ruby/object:Gem::Version
176
156
  version: '0'
177
157
  requirements: []
178
158
  rubyforge_project: assembly-image
179
- rubygems_version: 2.4.2
159
+ rubygems_version: 2.6.7
180
160
  signing_key:
181
161
  specification_version: 4
182
162
  summary: Ruby immplementation of image services needed to prepare objects to be accessioned
@@ -1,145 +0,0 @@
1
- = Assembly Image Gem
2
-
3
- ==Overview
4
- This gem contains classes used by the Stanford University Digital Library to perform
5
- image operations necessary for accessioning of content.
6
-
7
- ==Releases
8
-
9
- - 0.0.1 initial release
10
- - 0.0.2 small bug fixes
11
- - 0.0.3 more bug fixes
12
- - 0.0.4 update jp2 creation method to restrict allowed input types and improve color profile handling
13
- - 0.0.5 updated documentation to yard format
14
- - 0.0.6 updated dependency declarations
15
- - 0.1.0 move color profile extraction to tmp folder instead of gem profiles folder
16
- - 0.1.1 fix problem with digest require statement
17
- - 0.1.2 move check for file existence to when an action occurs instead of object initialization; more error checking and messages on command execution
18
- - 0.1.3 added a filesize attribute to the file object to allow easy access to filesize in bytes
19
- - 0.1.4 added a new images class that allows you batch create jp2s from an input TIFF directory
20
- - 0.2.0 added a new method to the image class to handle TIFF "sanity-check" -- can be used to ensure TIFFs are valid before JP2 generation
21
- - 1.0.0 bump the version number up to an official production level release
22
- - 1.1.0 remove common object file behaviors to a separate gem and use that gem as a dependency
23
- - 1.1.1 minor changes to spec tests
24
- - 1.1.2 remove the addition of 'format' node to file types in content metadata generation
25
- - 1.1.3 changes to content metadata generation method: change md5 and sha1 computations so that they come from the assembly-objectfile gem, and set preserve/publish/shelve attributes using mimetype defaults
26
- - 1.2.0 support tiffs that have embedded thumbnails when creating jp2
27
- - 1.2.1 raise a SecurityError if the user attempts to overwrite an existing jp2 when creating it, to make it easier to catch in assembly
28
- - 1.2.2 add height and width methods for an image that gets it from exif
29
- - 1.2.4 prepare for release listing on DLSS release board
30
- - 1.2.5 small change to use the jp2able method instead of the valid? method when creating jp2s
31
- - 1.2.6 update how version number is set to make it easier to show
32
- - 1.3.0 added a new method to the Assembly::Images class to allow for batch adding of color profiles to all tiffs in a directory; allow batch methods to run recursively
33
- - 1.3.1 remove content metadata generation method and add to assembly-objectfile gem instead
34
- - 1.3.3 update gemspec to force use of latest assembly-objectfile gem to allow gem to work in Ruby 1.9 projects
35
- - 1.3.4 update to latest version of lyberteam gems
36
- - 1.3.5 fix a problem that could occur if there were spaces in input filenames
37
- - 1.3.6 add new attribute to give you default jp2 filename that will be used
38
- - 1.3.7 add new attribute to give you default dpg jp2 filename
39
- - 1.3.8 allow for batch processing of image extensions other than tif
40
- - 1.3.9 create new methods for getting a color profile from exif and for force adding color profile to a single image
41
- - 1.4.0 and 1.4.1 set the imagemagick tmp folder location environment variable when creating jp2
42
- - 1.5.0 allow images with a color profile to have jp2 derivatives generated
43
- - 1.5.1 relax nokogiri version requirement
44
- - 1.6.1 bump version number of assembly-objectfile required to fix UTF-8 errors during JP2-create
45
- - 1.6.2-1.6.3 small change to jp2 generation to try and fix bug with tiffs that have multiple input profile layers
46
- - 1.6.4 added in some additional checks to try and create jp2s with mismatching exif data
47
- - 1.6.5-1.6.6 fix problem with lack of extension in incoming tif causing a problem when creating jp2
48
- - 1.6.7-1.6.8 tweaks to gemspec
49
- ==Notes
50
-
51
- 1. The gem assumes that the user context in which it is executed has write access to the 'tmp' folder.
52
- This is because color profiles can be extracted from images during the JP2 creation process, and these profiles need to
53
- be stored as local files, and it is beneficial to cache them for later usage by images with the same color profile.
54
- If you know there are color profiles which are commonly used, it is better to capture them in the gem itself in the profile
55
- folder so they can be re-used and do not need to be extracted.
56
-
57
- 2. If any errors occur during JP2 generation for any reason, a runtime exception will be thrown with a description of the error.
58
-
59
- 3. If an image is passed in with a color profile that cannot be determined by examining the exif header data, an exception will be thrown.
60
- This can commonally occur in basic test TIFs that are black/white and have no profile, so beware during testing.
61
-
62
- ==Deploy new gem
63
-
64
- gem build assembly-image.gemspec
65
- gem push assembly-image-1.6.8.gem # update version as needed
66
-
67
- ==Usage
68
-
69
- To use the JP2 creation method, you first instantiate the image object with an input image and then operate on it.
70
-
71
- require 'assembly-image'
72
- input=Assembly::Image.new('/full/path/to/file.tif')
73
- puts input.exif # this will show you exif header information for the TIF
74
- output=input.create_jp2(:output=>'/full/path/to/output.jp2') # this will generate a new JP2 in the output location specified
75
- puts output.exif # this will show you exif header information for the JP2
76
-
77
- ==Running tests
78
-
79
- bundle exec rspec spec
80
-
81
- ==Generate documentation
82
- To generate documentation into the "doc" folder:
83
-
84
- yard
85
-
86
- To keep a local server running with up to date code documentation that you can view in your browser at http://0.0.0.0:8808:
87
-
88
- yard server --reload
89
-
90
- ==Prerequisites
91
-
92
- 1. Perl
93
-
94
- 2. Kakadu Software Binaries - for JP2 generation
95
-
96
- Download and install demonstration binaries from Kakadu:
97
- http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22
98
-
99
- Note: The binaries will not work with RHEL 5.x; an RPM for RHEL 5 with
100
- compatible binaries coming soon.
101
-
102
- 3. Imagemagick 6.5.4 or higher
103
-
104
- RHEL 6
105
-
106
- The version of ImageMagick included with RHEL 6 has all of the dependency libraries included:
107
-
108
- yum install ImageMagick
109
-
110
- RHEL 5: (RPM to install with included binaries comming soon)
111
-
112
- The version of ImageMagic included with RHEL 5 is too old and does not have all the proper binaries included/built
113
-
114
- Required libraries are:
115
-
116
- yum install lcms lcms-devel libjpeg \
117
- libjpeg-devel libpng libpng-devel
118
-
119
- Required libraries from source:
120
- * libtiff (version 3.9.4 or higher)
121
-
122
- Build Imagemagick from source:
123
- http://www.imagemagick.org/download/ImageMagick.tar.gz
124
-
125
- Mac users:
126
-
127
- brew install jasper
128
- brew install libtiff
129
- brew install imagemagick --use-tiff --use-jpeg2000
130
-
131
- 4. Exiftool
132
-
133
- RHEL: (RPM to install comming soon)
134
- Download latest version from: http://www.sno.phy.queensu.ca/~phil/exiftool
135
-
136
- tar -xf Image-ExifTool-#.##.tar.gz
137
- cd Image-ExifTool-#.##
138
- perl Makefile.PL
139
- make test
140
- sudo make install
141
-
142
- Mac users:
143
-
144
- brew install exiftool
145
-