image_science 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -0
- data/.gemtest +0 -0
- data/History.txt +11 -0
- data/README.txt +4 -4
- data/Rakefile +3 -0
- data/lib/image_science.rb +38 -33
- metadata +96 -14
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
data/.gemtest
ADDED
File without changes
|
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 1.2.2 / 2012-03-13
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Extended build to look for homebrew setup (hcatlin)
|
6
|
+
|
7
|
+
* 2 bug fixes:
|
8
|
+
|
9
|
+
* Fixed 1.9 warnings, clang warnings, etc...
|
10
|
+
* Fixed compilation error when ruby's config mandates C89 style decls. (nocode)
|
11
|
+
|
1
12
|
=== 1.2.1 / 2009-08-14
|
2
13
|
|
3
14
|
* 2 minor enhancements:
|
data/README.txt
CHANGED
@@ -13,18 +13,18 @@ For more information including build steps, see http://seattlerb.rubyforge.org/
|
|
13
13
|
|
14
14
|
== FEATURES/PROBLEMS:
|
15
15
|
|
16
|
-
* Glorious graphics manipulation magi... errr, SCIENCE! in less than
|
16
|
+
* Glorious graphics manipulation magi... errr, SCIENCE! in less than 300 LoC!
|
17
17
|
* Supports square and proportional thumbnails, as well as arbitrary resizes.
|
18
18
|
* Pretty much any graphics format you could want. No really.
|
19
19
|
|
20
20
|
== SYNOPSYS:
|
21
21
|
|
22
|
-
ImageScience.with_image
|
23
|
-
img.cropped_thumbnail
|
22
|
+
ImageScience.with_image file do |img|
|
23
|
+
img.cropped_thumbnail 100 do |thumb|
|
24
24
|
thumb.save "#{file}_cropped.png"
|
25
25
|
end
|
26
26
|
|
27
|
-
img.thumbnail
|
27
|
+
img.thumbnail 100 do |thumb|
|
28
28
|
thumb.save "#{file}_thumb.png"
|
29
29
|
end
|
30
30
|
end
|
data/Rakefile
CHANGED
data/lib/image_science.rb
CHANGED
@@ -11,49 +11,46 @@ require 'inline'
|
|
11
11
|
# http://seattlerb.rubyforge.org/ImageScience.html
|
12
12
|
|
13
13
|
class ImageScience
|
14
|
-
VERSION = '1.2.
|
14
|
+
VERSION = '1.2.2'
|
15
15
|
|
16
16
|
##
|
17
17
|
# The top-level image loader opens +path+ and then yields the image.
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
#
|
19
|
+
# :singleton-method: with_image
|
21
20
|
|
22
21
|
##
|
23
|
-
# The top-level image loader, opens an image from the string +data+
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
# The top-level image loader, opens an image from the string +data+
|
23
|
+
# and then yields the image.
|
24
|
+
#
|
25
|
+
# :singleton-method: with_image_from_memory
|
27
26
|
|
28
27
|
##
|
29
28
|
# Crops an image to +left+, +top+, +right+, and +bottom+ and then
|
30
29
|
# yields the new image.
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
#
|
31
|
+
# :method: with_crop
|
34
32
|
|
35
33
|
##
|
36
34
|
# Returns the width of the image, in pixels.
|
37
|
-
|
38
|
-
|
35
|
+
#
|
36
|
+
# :method: width
|
39
37
|
|
40
38
|
##
|
41
39
|
# Returns the height of the image, in pixels.
|
42
|
-
|
43
|
-
|
40
|
+
#
|
41
|
+
# :method: height
|
44
42
|
|
45
43
|
##
|
46
44
|
# Saves the image out to +path+. Changing the file extension will
|
47
45
|
# convert the file type to the appropriate format.
|
48
|
-
|
49
|
-
|
46
|
+
#
|
47
|
+
# :method: save
|
50
48
|
|
51
49
|
##
|
52
50
|
# Resizes the image to +width+ and +height+ using a cubic-bspline
|
53
51
|
# filter and yields the new image.
|
54
|
-
|
55
|
-
|
56
|
-
end
|
52
|
+
#
|
53
|
+
# :method: resize
|
57
54
|
|
58
55
|
##
|
59
56
|
# Creates a proportional thumbnail of the image scaled so its longest
|
@@ -88,9 +85,11 @@ class ImageScience
|
|
88
85
|
end
|
89
86
|
|
90
87
|
inline do |builder|
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
%w[/opt/local /usr/local].each do |dir|
|
89
|
+
if File.directory? "#{dir}/include" then
|
90
|
+
builder.add_compile_flags "-I#{dir}/include"
|
91
|
+
builder.add_link_flags "-L#{dir}/lib"
|
92
|
+
end
|
94
93
|
end
|
95
94
|
|
96
95
|
builder.add_link_flags "-lfreeimage"
|
@@ -163,7 +162,7 @@ class ImageScience
|
|
163
162
|
FIBITMAP *bitmap;
|
164
163
|
VALUE result = Qnil;
|
165
164
|
flags = fif == FIF_JPEG ? JPEG_ACCURATE : 0;
|
166
|
-
if (bitmap = FreeImage_Load(fif, input, flags)) {
|
165
|
+
if ((bitmap = FreeImage_Load(fif, input, flags))) {
|
167
166
|
FITAG *tagValue = NULL;
|
168
167
|
FreeImage_GetMetadata(FIMD_EXIF_MAIN, bitmap, "Orientation", &tagValue);
|
169
168
|
switch (tagValue == NULL ? 0 : *((short *) FreeImage_GetTagValue(tagValue))) {
|
@@ -185,17 +184,24 @@ class ImageScience
|
|
185
184
|
return result;
|
186
185
|
}
|
187
186
|
rb_raise(rb_eTypeError, "Unknown file format");
|
187
|
+
return Qnil;
|
188
188
|
}
|
189
189
|
END
|
190
190
|
|
191
191
|
builder.c_singleton <<-"END"
|
192
192
|
VALUE with_image_from_memory(VALUE image_data) {
|
193
193
|
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
194
|
+
BYTE *image_data_ptr;
|
195
|
+
DWORD image_data_length;
|
196
|
+
FIMEMORY *stream;
|
197
|
+
FIBITMAP *bitmap = NULL;
|
198
|
+
VALUE result = Qnil;
|
199
|
+
int flags;
|
194
200
|
|
195
201
|
Check_Type(image_data, T_STRING);
|
196
|
-
|
197
|
-
|
198
|
-
|
202
|
+
image_data_ptr = (BYTE*)RSTRING_PTR(image_data);
|
203
|
+
image_data_length = (DWORD)RSTRING_LEN(image_data);
|
204
|
+
stream = FreeImage_OpenMemory(image_data_ptr, image_data_length);
|
199
205
|
|
200
206
|
if (NULL == stream) {
|
201
207
|
rb_raise(rb_eTypeError, "Unable to open image_data");
|
@@ -206,9 +212,7 @@ class ImageScience
|
|
206
212
|
rb_raise(rb_eTypeError, "Unknown file format");
|
207
213
|
}
|
208
214
|
|
209
|
-
|
210
|
-
VALUE result = Qnil;
|
211
|
-
int flags = fif == FIF_JPEG ? JPEG_ACCURATE : 0;
|
215
|
+
flags = fif == FIF_JPEG ? JPEG_ACCURATE : 0;
|
212
216
|
bitmap = FreeImage_LoadFromMemory(fif, stream, flags);
|
213
217
|
FreeImage_CloseMemory(stream);
|
214
218
|
if (bitmap) {
|
@@ -224,7 +228,7 @@ class ImageScience
|
|
224
228
|
VALUE result = Qnil;
|
225
229
|
GET_BITMAP(bitmap);
|
226
230
|
|
227
|
-
if (copy = FreeImage_Copy(bitmap, l, t, r, b)) {
|
231
|
+
if ((copy = FreeImage_Copy(bitmap, l, t, r, b))) {
|
228
232
|
copy_icc_profile(self, bitmap, copy);
|
229
233
|
result = wrap_and_yield(copy, self, 0);
|
230
234
|
}
|
@@ -251,7 +255,7 @@ class ImageScience
|
|
251
255
|
END
|
252
256
|
|
253
257
|
builder.c <<-"END"
|
254
|
-
VALUE resize(
|
258
|
+
VALUE resize(int w, int h) {
|
255
259
|
FIBITMAP *bitmap, *image;
|
256
260
|
if (w <= 0) rb_raise(rb_eArgError, "Width <= 0");
|
257
261
|
if (h <= 0) rb_raise(rb_eArgError, "Height <= 0");
|
@@ -272,9 +276,9 @@ class ImageScience
|
|
272
276
|
FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(output);
|
273
277
|
if (fif == FIF_UNKNOWN) fif = FIX2INT(rb_iv_get(self, "@file_type"));
|
274
278
|
if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsWriting(fif)) {
|
279
|
+
BOOL result = 0, unload = 0;
|
275
280
|
GET_BITMAP(bitmap);
|
276
281
|
flags = fif == FIF_JPEG ? JPEG_QUALITYSUPERB : 0;
|
277
|
-
BOOL result = 0, unload = 0;
|
278
282
|
|
279
283
|
if (fif == FIF_PNG) FreeImage_DestroyICCProfile(bitmap);
|
280
284
|
if (fif == FIF_JPEG && FreeImage_GetBPP(bitmap) != 24)
|
@@ -287,6 +291,7 @@ class ImageScience
|
|
287
291
|
return result ? Qtrue : Qfalse;
|
288
292
|
}
|
289
293
|
rb_raise(rb_eTypeError, "Unknown file format");
|
294
|
+
return Qnil;
|
290
295
|
}
|
291
296
|
END
|
292
297
|
end
|
metadata
CHANGED
@@ -1,27 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_science
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Ryan Davis
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
|
-
cert_chain:
|
16
|
+
cert_chain:
|
17
|
+
- |
|
18
|
+
-----BEGIN CERTIFICATE-----
|
19
|
+
MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
20
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
21
|
+
GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
|
22
|
+
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
23
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
24
|
+
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
25
|
+
taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
|
26
|
+
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
27
|
+
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
28
|
+
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
29
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
30
|
+
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
|
37
|
+
-----END CERTIFICATE-----
|
11
38
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
39
|
+
date: 2012-03-13 00:00:00 Z
|
14
40
|
dependencies:
|
15
41
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
42
|
+
name: RubyInline
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 21
|
50
|
+
segments:
|
51
|
+
- 3
|
52
|
+
- 9
|
53
|
+
version: "3.9"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id001
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 21
|
65
|
+
segments:
|
66
|
+
- 2
|
67
|
+
- 11
|
68
|
+
version: "2.11"
|
17
69
|
type: :development
|
18
|
-
|
19
|
-
|
70
|
+
version_requirements: *id002
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rdoc
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
20
76
|
requirements:
|
21
|
-
- -
|
77
|
+
- - ~>
|
22
78
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
79
|
+
hash: 19
|
80
|
+
segments:
|
81
|
+
- 3
|
82
|
+
- 10
|
83
|
+
version: "3.10"
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id003
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: hoe
|
88
|
+
prerelease: false
|
89
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 29
|
95
|
+
segments:
|
96
|
+
- 2
|
97
|
+
- 15
|
98
|
+
version: "2.15"
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id004
|
25
101
|
description: |-
|
26
102
|
ImageScience is a clean and happy Ruby library that generates
|
27
103
|
thumbnails -- and kicks the living crap out of RMagick. Oh, and it
|
@@ -48,7 +124,7 @@ files:
|
|
48
124
|
- lib/image_science.rb
|
49
125
|
- test/pix.png
|
50
126
|
- test/test_image_science.rb
|
51
|
-
|
127
|
+
- .gemtest
|
52
128
|
homepage: http://seattlerb.rubyforge.org/ImageScience.html
|
53
129
|
licenses: []
|
54
130
|
|
@@ -59,21 +135,27 @@ rdoc_options:
|
|
59
135
|
require_paths:
|
60
136
|
- lib
|
61
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
62
139
|
requirements:
|
63
140
|
- - ">="
|
64
141
|
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
65
145
|
version: "0"
|
66
|
-
version:
|
67
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
68
148
|
requirements:
|
69
149
|
- - ">="
|
70
150
|
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
71
154
|
version: "0"
|
72
|
-
version:
|
73
155
|
requirements: []
|
74
156
|
|
75
157
|
rubyforge_project: seattlerb
|
76
|
-
rubygems_version: 1.
|
158
|
+
rubygems_version: 1.8.12
|
77
159
|
signing_key:
|
78
160
|
specification_version: 3
|
79
161
|
summary: ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick
|
metadata.gz.sig
ADDED
Binary file
|