image_science 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f4c2bf100b9b9c8b0fc90434c2457f59ad04413
4
+ data.tar.gz: 27a8915d9d58366d4f780087e6518a75ba97772e
5
+ SHA512:
6
+ metadata.gz: 14f8f590cc4ff27fd8604b6dfcd6fe0ef38ec3e80ec03a896f79383e2e136d8c12418f6366afa661dbc6a83c5f7bcf17587e7c51d9df70473f37f8001fcb4799
7
+ data.tar.gz: 65c54429309c45b2547a278b7e0a0d109645392e17f31f7c4af12cebd44b64813624980a111fef2e0ce710f8883978f0c269f04b1c1396954140eeaf04b0737b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ === 1.2.6 / 2014-01-15
2
+
3
+ * 1 bug fix:
4
+
5
+ * Defer raising exception until wrapped by rb_ensure. (nocode)
6
+
1
7
  === 1.2.5 / 2013-06-20
2
8
 
3
9
  * 1 bug fix:
data/Rakefile CHANGED
@@ -8,13 +8,17 @@ Hoe.add_include_dirs("../../RubyInline/dev/lib",
8
8
 
9
9
  Hoe.plugin :seattlerb
10
10
  Hoe.plugin :inline
11
+ Hoe.plugin :isolate
11
12
 
12
13
  Hoe.spec 'image_science' do
13
14
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
14
15
 
15
- self.rubyforge_name = 'seattlerb'
16
-
17
16
  clean_globs << 'blah*png' << 'images/*_thumb.*'
18
17
  end
19
18
 
19
+ task :debug => :isolate do
20
+ file = ENV["F"]
21
+ ruby "-Ilib bin/image_science_thumb 100 #{file}"
22
+ end
23
+
20
24
  # vim: syntax=Ruby
@@ -11,7 +11,7 @@ require 'inline'
11
11
  # http://seattlerb.rubyforge.org/ImageScience.html
12
12
 
13
13
  class ImageScience
14
- VERSION = '1.2.5'
14
+ VERSION = '1.2.6'
15
15
 
16
16
  ##
17
17
  # The top-level image loader opens +path+ and then yields the image.
@@ -104,6 +104,8 @@ class ImageScience
104
104
 
105
105
  builder.prefix <<-"END"
106
106
  #define GET_BITMAP(name) Data_Get_Struct(self, FIBITMAP, (name)); if (!(name)) rb_raise(rb_eTypeError, "Bitmap has already been freed");
107
+ static ID err_key; /* used as thread-local key */
108
+ static void raise_deferred(void);
107
109
  END
108
110
 
109
111
  builder.prefix <<-"END"
@@ -113,18 +115,29 @@ class ImageScience
113
115
 
114
116
  FreeImage_Unload(bitmap);
115
117
  DATA_PTR(self) = NULL;
118
+ raise_deferred(); /* raise just in case */
116
119
  return Qnil;
117
120
  }
118
121
  END
119
122
 
120
123
  builder.prefix <<-"END"
124
+ static VALUE raise_or_yield(VALUE obj) {
125
+ /*
126
+ * check for FreeImage routines which may warn or error out,
127
+ * do not run user code if there are warnings/errors here:
128
+ */
129
+ raise_deferred();
130
+
131
+ return rb_yield(obj);
132
+ }
133
+
121
134
  VALUE wrap_and_yield(FIBITMAP *image, VALUE self, FREE_IMAGE_FORMAT fif) {
122
135
  unsigned int self_is_class = rb_type(self) == T_CLASS;
123
136
  VALUE klass = self_is_class ? self : CLASS_OF(self);
124
137
  VALUE type = self_is_class ? INT2FIX(fif) : rb_iv_get(self, "@file_type");
125
138
  VALUE obj = Data_Wrap_Struct(klass, NULL, NULL, image);
126
139
  rb_iv_set(obj, "@file_type", type);
127
- return rb_ensure(rb_yield, obj, unload, obj);
140
+ return rb_ensure(raise_or_yield, obj, unload, obj);
128
141
  }
129
142
  END
130
143
 
@@ -140,12 +153,28 @@ class ImageScience
140
153
  }
141
154
  END
142
155
 
156
+ # we defer raising the error until it we find a safe point to do so
157
+ # We cannot use rb_ensure in these cases because FreeImage may internally
158
+ # make allocations via which our code will never see.
143
159
  builder.prefix <<-"END"
144
160
  void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
145
- rb_raise(rb_eRuntimeError,
161
+ VALUE err = rb_sprintf(
146
162
  "FreeImage exception for type %s: %s",
147
163
  (fif == FIF_UNKNOWN) ? "???" : FreeImage_GetFormatFromFIF(fif),
148
164
  message);
165
+ rb_thread_local_aset(rb_thread_current(), err_key, err);
166
+ }
167
+ END
168
+
169
+ # do not call this until necessary variables are wrapped up for GC
170
+ # otherwise there will be leaks
171
+ builder.prefix <<-"END"
172
+ static void raise_deferred(void) {
173
+ VALUE err = rb_thread_local_aref(rb_thread_current(), err_key);
174
+ if (!NIL_P(err)) {
175
+ rb_thread_local_aset(rb_thread_current(), err_key, Qnil);
176
+ rb_raise(rb_eRuntimeError, "%s", StringValueCStr(err));
177
+ }
149
178
  }
150
179
  END
151
180
 
@@ -174,6 +203,7 @@ class ImageScience
174
203
  END
175
204
 
176
205
  builder.add_to_init "FreeImage_SetOutputMessage(FreeImageErrorHandler);"
206
+ builder.add_to_init 'err_key = rb_intern("__FREE_IMAGE_ERROR");'
177
207
 
178
208
  builder.c_singleton <<-"END"
179
209
  VALUE with_image(char * input) {
@@ -190,6 +220,7 @@ class ImageScience
190
220
  bitmap = ReOrient(bitmap);
191
221
  result = wrap_and_yield(bitmap, self, fif);
192
222
  }
223
+ raise_deferred();
193
224
  return result;
194
225
  }
195
226
  rb_raise(rb_eTypeError, "Unknown file format");
@@ -228,6 +259,7 @@ class ImageScience
228
259
  bitmap = ReOrient(bitmap);
229
260
  result = wrap_and_yield(bitmap, self, fif);
230
261
  }
262
+ raise_deferred();
231
263
  return result;
232
264
  }
233
265
  END
@@ -242,6 +274,7 @@ class ImageScience
242
274
  copy_icc_profile(self, bitmap, copy);
243
275
  result = wrap_and_yield(copy, self, 0);
244
276
  }
277
+ raise_deferred();
245
278
  return result;
246
279
  }
247
280
  END
@@ -275,6 +308,7 @@ class ImageScience
275
308
  copy_icc_profile(self, bitmap, image);
276
309
  return wrap_and_yield(image, self, 0);
277
310
  }
311
+ raise_deferred();
278
312
  return Qnil;
279
313
  }
280
314
  END
@@ -298,6 +332,7 @@ class ImageScience
298
332
 
299
333
  if (unload) FreeImage_Unload(bitmap);
300
334
 
335
+ raise_deferred();
301
336
  return result ? Qtrue : Qfalse;
302
337
  }
303
338
  rb_raise(rb_eTypeError, "Unknown file format");
metadata CHANGED
@@ -1,24 +1,18 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: image_science
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 5
10
- version: 1.2.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.6
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Ryan Davis
14
8
  autorequire:
15
9
  bindir: bin
16
- cert_chain:
10
+ cert_chain:
17
11
  - |
18
12
  -----BEGIN CERTIFICATE-----
19
- MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
20
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
21
- GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTEzMDkxNjIzMDQxMloXDTE0MDkxNjIzMDQxMlowRTETMBEGA1UE
22
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
23
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
24
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -28,93 +22,88 @@ cert_chain:
28
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
29
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
30
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
31
- AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
32
- vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
33
- w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
34
- l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
35
- n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
36
- FBHgymkyj/AOSqKRIpXPhjC6
25
+ AQCFZ7JTzoy1gcG4d8A6dmOJy7ygtO5MFpRIz8HuKCF5566nOvpy7aHhDDzFmQuu
26
+ FX3zDU6ghx5cQIueDhf2SGOncyBmmJRRYawm3wI0o1MeN6LZJ/3cRaOTjSFy6+S6
27
+ zqDmHBp8fVA2TGJtO0BLNkbGVrBJjh0UPmSoGzWlRhEVnYC33TpDAbNA+u39UrQI
28
+ ynwhNN7YbnmSR7+JU2cUjBFv2iPBO+TGuWC+9L2zn3NHjuc6tnmSYipA9y8Hv+As
29
+ Y4evBVezr3SjXz08vPqRO5YRdO3zfeMT8gBjRqZjWJGMZ2lD4XNfrs7eky74CyZw
30
+ xx3n58i0lQkBE1EpKE0lFu/y
37
31
  -----END CERTIFICATE-----
38
-
39
- date: 2013-06-21 00:00:00 Z
40
- dependencies:
41
- - !ruby/object:Gem::Dependency
32
+ date: 2014-01-16 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
42
35
  name: RubyInline
43
- prerelease: false
44
- requirement: &id001 !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
47
38
  - - ~>
48
- - !ruby/object:Gem::Version
49
- hash: 21
50
- segments:
51
- - 3
52
- - 9
53
- version: "3.9"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.9'
54
41
  type: :runtime
55
- version_requirements: *id001
56
- - !ruby/object:Gem::Dependency
57
- name: minitest
58
42
  prerelease: false
59
- requirement: &id002 !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ - !ruby/object:Gem::Dependency
49
+ name: minitest
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
62
52
  - - ~>
63
- - !ruby/object:Gem::Version
64
- hash: 31
65
- segments:
66
- - 5
67
- - 0
68
- version: "5.0"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.2'
69
55
  type: :development
70
- version_requirements: *id002
71
- - !ruby/object:Gem::Dependency
72
- name: rdoc
73
56
  prerelease: false
74
- requirement: &id003 !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '5.2'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
77
66
  - - ~>
78
- - !ruby/object:Gem::Version
79
- hash: 27
80
- segments:
81
- - 4
82
- - 0
83
- version: "4.0"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
84
69
  type: :development
85
- version_requirements: *id003
86
- - !ruby/object:Gem::Dependency
87
- name: hoe
88
70
  prerelease: false
89
- requirement: &id004 !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
92
73
  - - ~>
93
- - !ruby/object:Gem::Version
94
- hash: 11
95
- segments:
96
- - 3
97
- - 6
98
- version: "3.6"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: hoe
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3.8'
99
83
  type: :development
100
- version_requirements: *id004
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '3.8'
101
90
  description: |-
102
91
  ImageScience is a clean and happy Ruby library that generates
103
92
  thumbnails -- and kicks the living crap out of RMagick. Oh, and it
104
93
  doesn't leak memory like a sieve. :)
105
-
94
+
106
95
  For more information including build steps, see http://seattlerb.rubyforge.org/
107
- email:
96
+ email:
108
97
  - ryand-ruby@zenspider.com
109
- executables:
98
+ executables:
110
99
  - image_science_thumb
111
100
  extensions: []
112
-
113
- extra_rdoc_files:
101
+ extra_rdoc_files:
114
102
  - History.txt
115
103
  - Manifest.txt
116
104
  - README.txt
117
- files:
105
+ files:
106
+ - .gemtest
118
107
  - History.txt
119
108
  - Manifest.txt
120
109
  - README.txt
@@ -125,40 +114,32 @@ files:
125
114
  - test/pix.png
126
115
  - test/portrait.jpg
127
116
  - test/test_image_science.rb
128
- - .gemtest
129
117
  homepage: http://seattlerb.rubyforge.org/ImageScience.html
130
- licenses: []
131
-
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
132
121
  post_install_message:
133
- rdoc_options:
122
+ rdoc_options:
134
123
  - --main
135
124
  - README.txt
136
- require_paths:
125
+ require_paths:
137
126
  - lib
138
- required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
- version: "0"
147
- required_rubygems_version: !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- hash: 3
153
- segments:
154
- - 0
155
- version: "0"
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
156
137
  requirements: []
157
-
158
- rubyforge_project: seattlerb
159
- rubygems_version: 1.8.25
138
+ rubyforge_project: image_science
139
+ rubygems_version: 2.2.1
160
140
  signing_key:
161
- specification_version: 3
162
- summary: ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick
163
- test_files:
141
+ specification_version: 4
142
+ summary: ImageScience is a clean and happy Ruby library that generates thumbnails
143
+ -- and kicks the living crap out of RMagick
144
+ test_files:
164
145
  - test/test_image_science.rb
metadata.gz.sig CHANGED
Binary file