g1nn13-image_science 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ P엸�����=x�+%~�����V�)�7�+�{E3`��b����ٟh�ȸ�8�{�>fo��
2
+ F��Z=yN���
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.2.8 / 2010-05-27
2
+
3
+ * re-added C code for buffer method. This was lost in the 1.2.6 merge.
4
+ * added a clarifying comment to the docs for buffer()
5
+
1
6
  === 1.2.7 / 2010-05-26
2
7
 
3
8
  * removed redundant method cropped_to_fit
data/lib/image_science.rb CHANGED
@@ -13,7 +13,7 @@ require 'inline'
13
13
  # Based on ImageScience 1.2.1
14
14
 
15
15
  class ImageScience
16
- VERSION = '1.2.7'
16
+ VERSION = '1.2.8'
17
17
 
18
18
  ##
19
19
  # The top-level image loader opens +path+ and then yields the image.
@@ -53,8 +53,9 @@ class ImageScience
53
53
  ##
54
54
  # Returns the image in a buffer (String). Changing the file
55
55
  # extension converts the file type to the appropriate format.
56
-
57
- def buffer(extension) # :yields: image
56
+ # Note: *returns*! Does not yield!
57
+
58
+ def buffer(extension) # :returns: string
58
59
  end
59
60
 
60
61
  ##
@@ -395,5 +396,50 @@ return result ? Qtrue : Qfalse;
395
396
  rb_raise(rb_eTypeError, "Unknown file format");
396
397
  }
397
398
  END
399
+
400
+ builder.c <<-"END"
401
+ VALUE buffer(char * extension) {
402
+ VALUE str;
403
+ int flags;
404
+ FIBITMAP *bitmap;
405
+ FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(extension);
406
+ FIMEMORY *mem = NULL;
407
+ long file_size;
408
+ BYTE *mem_buffer = NULL;
409
+ DWORD size_in_bytes = 0;
410
+
411
+ if (fif == FIF_UNKNOWN) fif = FIX2INT(rb_iv_get(self, "@file_type"));
412
+ if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsWriting(fif)) {
413
+ GET_BITMAP(bitmap);
414
+ flags = fif == FIF_JPEG ? JPEG_QUALITYSUPERB : 0;
415
+ BOOL result = 0, unload = 0;
416
+
417
+ if (fif == FIF_PNG) FreeImage_DestroyICCProfile(bitmap);
418
+ if (fif == FIF_JPEG && FreeImage_GetBPP(bitmap) != 24)
419
+ bitmap = FreeImage_ConvertTo24Bits(bitmap), unload = 1; // sue me
420
+
421
+ mem = FreeImage_OpenMemory(0,0);
422
+ result = FreeImage_SaveToMemory(fif, bitmap, mem, flags);
423
+
424
+ // get the buffer from the memory stream
425
+ FreeImage_AcquireMemory(mem, &mem_buffer, &size_in_bytes);
426
+
427
+ // convert to ruby string
428
+ str = rb_str_new(mem_buffer, size_in_bytes);
429
+
430
+ // clean up
431
+ if (unload) FreeImage_Unload(bitmap);
432
+ FreeImage_CloseMemory(mem);
433
+
434
+ if (result) {
435
+ return str;
436
+ } else {
437
+ return Qfalse;
438
+ }
439
+ }
440
+ rb_raise(rb_eTypeError, "Unknown file format");
441
+ }
442
+ END
443
+
398
444
  end
399
445
  end
@@ -114,23 +114,17 @@ class TestImageScience < MiniTest::Unit::TestCase
114
114
  def test_buffer_return
115
115
  ImageScience.with_image @pix do |img|
116
116
  img.resize(25, 25) do |thumb|
117
- # assert thumb.buffer('.jpg')
117
+ buffer = thumb.buffer('.jpg')
118
+ assert buffer
119
+ assert buffer.length > 0
118
120
  thumb.buffer('.jpg') do |buffer|
119
121
  assert buffer
122
+ assert buffer.length > 0
120
123
  end
121
124
  end
122
125
  end
123
126
  end
124
127
 
125
- def test_buffer_yield
126
- ImageScience.with_image @pix do |img|
127
- img.resize(25, 25) do |thumb|
128
- thumb.buffer('.jpg') do |buffer|
129
- assert buffer
130
- end
131
- end
132
- end
133
- end
134
128
 
135
129
  def test_resize_floats
136
130
  ImageScience.with_image @pix do |img|
metadata CHANGED
@@ -1,87 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g1nn13-image_science
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 2
8
+ - 8
9
+ version: 1.2.8
5
10
  platform: ruby
6
11
  authors:
7
12
  - jim nist
8
13
  autorequire:
9
14
  bindir: bin
10
- cert_chain: []
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQwwCgYDVQQDDANqaW0x
19
+ HDAaBgoJkiaJk/IsZAEZFgxob3RlbGljb3B0ZXIxEzARBgoJkiaJk/IsZAEZFgNj
20
+ b20wHhcNMTAwNTI2MTYwNTM5WhcNMTEwNTI2MTYwNTM5WjBBMQwwCgYDVQQDDANq
21
+ aW0xHDAaBgoJkiaJk/IsZAEZFgxob3RlbGljb3B0ZXIxEzARBgoJkiaJk/IsZAEZ
22
+ FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzbudw4TyxDTEj
23
+ /UMsEt2LFWmDiEKmyKHnHiPdjINn/wY8yYw1oujRj2c2iXlaon68u8G+1qacfyd0
24
+ gpHPFQfqBFKLDtPgPffzAkY8fvW4MgjRYFcymdpiVGpHCoTgvhO9Efsrd/d8Ja4n
25
+ oeEPNHdXr/bHwLhgIAup6JYQAZSL1DY77co3rbvY1xqovbc6tg/M7cbXPp1lmONS
26
+ XwIHPWjsl3mL1IWEQPt2dmPy6ZLYliKowdGlDUblupXuVlO9cS67yf3MlJp874mY
27
+ yH1qAwSK/Toe2L39TTi/Hyx6HMFECTmkLUT/4X2z6zWUlK0e5Hr8ViBCzh2BTOyO
28
+ jojoYo7tAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
29
+ BBQ1LMdE7DCtf+7x6tJAqGRMKMtVXDANBgkqhkiG9w0BAQUFAAOCAQEAIu7ygDoV
30
+ g5wdi3wWR//1yK86vQe36luyolo3GL+Z0FmIIA+tdAPZtMAlnFasOSfLVDdkxb3O
31
+ J2MLyH5KHY5asc27J+Y/zUofGWj5JgQZIg+gAGcDuq94kr4NXgFTL4khE3zhI4uH
32
+ 65+zkHrnetmZPilpTbFjzvM1SfuzrU9t+ugEu7R1vmAQdhdcgSwXr0MYPy5oZWgQ
33
+ eayeSBRjd6tzceXRmaZYWDH2wra509l63UgJw6dsNgWzQH1XQ1XzqJXX/J8FRgDI
34
+ n3ugwImcS/YB+ZQ3TQ3uKX8E5Ikos7YH0Pc/WRQnMzcjBmNtx7GsV9MC9Qx/i+YC
35
+ UHHftgnvI+YPGw==
36
+ -----END CERTIFICATE-----
11
37
 
12
- date: 2010-05-26 00:00:00 -04:00
38
+ date: 2010-05-27 00:00:00 -04:00
13
39
  default_executable:
14
40
  dependencies:
15
41
  - !ruby/object:Gem::Dependency
16
42
  name: hoe
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
20
45
  requirements:
21
46
  - - ">="
22
47
  - !ruby/object:Gem::Version
48
+ segments:
49
+ - 2
50
+ - 5
51
+ - 0
23
52
  version: 2.5.0
24
- version:
53
+ type: :runtime
54
+ version_requirements: *id001
25
55
  - !ruby/object:Gem::Dependency
26
56
  name: gemcutter
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
57
+ prerelease: false
58
+ requirement: &id002 !ruby/object:Gem::Requirement
30
59
  requirements:
31
60
  - - ">="
32
61
  - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ - 3
65
+ - 0
33
66
  version: 0.3.0
34
- version:
67
+ type: :runtime
68
+ version_requirements: *id002
35
69
  - !ruby/object:Gem::Dependency
36
70
  name: hoe-doofus
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id003 !ruby/object:Gem::Requirement
40
73
  requirements:
41
74
  - - ">="
42
75
  - !ruby/object:Gem::Version
76
+ segments:
77
+ - 1
78
+ - 0
79
+ - 0
43
80
  version: 1.0.0
44
- version:
81
+ type: :development
82
+ version_requirements: *id003
45
83
  - !ruby/object:Gem::Dependency
46
84
  name: hoe-git
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
85
+ prerelease: false
86
+ requirement: &id004 !ruby/object:Gem::Requirement
50
87
  requirements:
51
88
  - - ">="
52
89
  - !ruby/object:Gem::Version
90
+ segments:
91
+ - 1
92
+ - 3
93
+ - 0
53
94
  version: 1.3.0
54
- version:
95
+ type: :development
96
+ version_requirements: *id004
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: hoe-telicopter
57
- type: :development
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
99
+ prerelease: false
100
+ requirement: &id005 !ruby/object:Gem::Requirement
60
101
  requirements:
61
102
  - - ">="
62
103
  - !ruby/object:Gem::Version
104
+ segments:
105
+ - 1
106
+ - 0
107
+ - 0
63
108
  version: 1.0.0
64
- version:
109
+ type: :development
110
+ version_requirements: *id005
65
111
  - !ruby/object:Gem::Dependency
66
112
  name: minitest
67
- type: :development
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
113
+ prerelease: false
114
+ requirement: &id006 !ruby/object:Gem::Requirement
70
115
  requirements:
71
116
  - - ">="
72
117
  - !ruby/object:Gem::Version
118
+ segments:
119
+ - 1
120
+ - 5
121
+ - 0
73
122
  version: 1.5.0
74
- version:
123
+ type: :development
124
+ version_requirements: *id006
75
125
  - !ruby/object:Gem::Dependency
76
126
  name: hoe
77
- type: :development
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
127
+ prerelease: false
128
+ requirement: &id007 !ruby/object:Gem::Requirement
80
129
  requirements:
81
130
  - - ">="
82
131
  - !ruby/object:Gem::Version
132
+ segments:
133
+ - 2
134
+ - 6
135
+ - 0
83
136
  version: 2.6.0
84
- version:
137
+ type: :development
138
+ version_requirements: *id007
85
139
  description: |-
86
140
  g1nn13 fork changes:
87
141
 
@@ -138,18 +192,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
192
  requirements:
139
193
  - - ">="
140
194
  - !ruby/object:Gem::Version
195
+ segments:
196
+ - 0
141
197
  version: "0"
142
- version:
143
198
  required_rubygems_version: !ruby/object:Gem::Requirement
144
199
  requirements:
145
200
  - - ">="
146
201
  - !ruby/object:Gem::Version
202
+ segments:
203
+ - 0
147
204
  version: "0"
148
- version:
149
205
  requirements: []
150
206
 
151
207
  rubyforge_project: g1nn13-image_science
152
- rubygems_version: 1.3.5
208
+ rubygems_version: 1.3.6
153
209
  signing_key:
154
210
  specification_version: 3
155
211
  summary: "g1nn13 fork changes: * added buffer() method to get image buffer for writing (to Amazon S3) * added fit_within() method to resize an image to fit within a specified height and width without changing the image's aspect ratio * added resize_with_crop() to resize and crop images where the target aspect ratio differs from the original aspect ratio"
metadata.gz.sig ADDED
Binary file