image_science 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +1 -0
- data/lib/image_science.rb +24 -17
- data/test/portrait.jpg +0 -0
- data/test/test_image_science.rb +14 -0
- metadata +13 -12
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/image_science.rb
CHANGED
@@ -11,7 +11,7 @@ require 'inline'
|
|
11
11
|
# http://seattlerb.rubyforge.org/ImageScience.html
|
12
12
|
|
13
13
|
class ImageScience
|
14
|
-
VERSION = '1.2.
|
14
|
+
VERSION = '1.2.4'
|
15
15
|
|
16
16
|
##
|
17
17
|
# The top-level image loader opens +path+ and then yields the image.
|
@@ -149,6 +149,27 @@ class ImageScience
|
|
149
149
|
}
|
150
150
|
END
|
151
151
|
|
152
|
+
builder.prefix <<-"END"
|
153
|
+
FIBITMAP* ReOrient(FIBITMAP *bitmap) {
|
154
|
+
FITAG *tagValue = NULL;
|
155
|
+
FreeImage_GetMetadata(FIMD_EXIF_MAIN, bitmap, "Orientation", &tagValue);
|
156
|
+
switch (tagValue == NULL ? 0 : *((short *) FreeImage_GetTagValue(tagValue))) {
|
157
|
+
case 6:
|
158
|
+
bitmap = FreeImage_RotateClassic(bitmap, 270);
|
159
|
+
break;
|
160
|
+
case 3:
|
161
|
+
bitmap = FreeImage_RotateClassic(bitmap, 180);
|
162
|
+
break;
|
163
|
+
case 8:
|
164
|
+
bitmap = FreeImage_RotateClassic(bitmap, 90);
|
165
|
+
break;
|
166
|
+
default:
|
167
|
+
break;
|
168
|
+
}
|
169
|
+
return bitmap;
|
170
|
+
}
|
171
|
+
END
|
172
|
+
|
152
173
|
builder.add_to_init "FreeImage_SetOutputMessage(FreeImageErrorHandler);"
|
153
174
|
|
154
175
|
builder.c_singleton <<-"END"
|
@@ -163,22 +184,7 @@ class ImageScience
|
|
163
184
|
VALUE result = Qnil;
|
164
185
|
flags = fif == FIF_JPEG ? JPEG_ACCURATE : 0;
|
165
186
|
if ((bitmap = FreeImage_Load(fif, input, flags))) {
|
166
|
-
|
167
|
-
FreeImage_GetMetadata(FIMD_EXIF_MAIN, bitmap, "Orientation", &tagValue);
|
168
|
-
switch (tagValue == NULL ? 0 : *((short *) FreeImage_GetTagValue(tagValue))) {
|
169
|
-
case 6:
|
170
|
-
bitmap = FreeImage_RotateClassic(bitmap, 270);
|
171
|
-
break;
|
172
|
-
case 3:
|
173
|
-
bitmap = FreeImage_RotateClassic(bitmap, 180);
|
174
|
-
break;
|
175
|
-
case 8:
|
176
|
-
bitmap = FreeImage_RotateClassic(bitmap, 90);
|
177
|
-
break;
|
178
|
-
default:
|
179
|
-
break;
|
180
|
-
}
|
181
|
-
|
187
|
+
bitmap = ReOrient(bitmap);
|
182
188
|
result = wrap_and_yield(bitmap, self, fif);
|
183
189
|
}
|
184
190
|
return result;
|
@@ -216,6 +222,7 @@ class ImageScience
|
|
216
222
|
bitmap = FreeImage_LoadFromMemory(fif, stream, flags);
|
217
223
|
FreeImage_CloseMemory(stream);
|
218
224
|
if (bitmap) {
|
225
|
+
bitmap = ReOrient(bitmap);
|
219
226
|
result = wrap_and_yield(bitmap, self, fif);
|
220
227
|
}
|
221
228
|
return result;
|
data/test/portrait.jpg
ADDED
Binary file
|
data/test/test_image_science.rb
CHANGED
@@ -174,4 +174,18 @@ class TestImageScience < MiniTest::Unit::TestCase
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
+
def test_auto_rotate_from_file
|
178
|
+
ImageScience.with_image "test/portrait.jpg" do |img|
|
179
|
+
assert_equal 50, img.height
|
180
|
+
assert_equal 38, img.width
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_auto_rotate_from_memory
|
185
|
+
data = File.new("test/portrait.jpg").binmode.read
|
186
|
+
ImageScience.with_image_from_memory data do |img|
|
187
|
+
assert_equal 50, img.height
|
188
|
+
assert_equal 38, img.width
|
189
|
+
end
|
190
|
+
end
|
177
191
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_science
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2012-
|
39
|
+
date: 2012-11-23 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: RubyInline
|
@@ -61,11 +61,11 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 29
|
65
65
|
segments:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
version: "
|
66
|
+
- 4
|
67
|
+
- 3
|
68
|
+
version: "4.3"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id002
|
71
71
|
- !ruby/object:Gem::Dependency
|
@@ -91,11 +91,11 @@ dependencies:
|
|
91
91
|
requirements:
|
92
92
|
- - ~>
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
hash:
|
94
|
+
hash: 1
|
95
95
|
segments:
|
96
96
|
- 3
|
97
|
-
-
|
98
|
-
version: "3.
|
97
|
+
- 3
|
98
|
+
version: "3.3"
|
99
99
|
type: :development
|
100
100
|
version_requirements: *id004
|
101
101
|
description: |-
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- bin/image_science_thumb
|
124
124
|
- lib/image_science.rb
|
125
125
|
- test/pix.png
|
126
|
+
- test/portrait.jpg
|
126
127
|
- test/test_image_science.rb
|
127
128
|
- .gemtest
|
128
129
|
homepage: http://seattlerb.rubyforge.org/ImageScience.html
|
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
requirements: []
|
156
157
|
|
157
158
|
rubyforge_project: seattlerb
|
158
|
-
rubygems_version: 1.8.
|
159
|
+
rubygems_version: 1.8.24
|
159
160
|
signing_key:
|
160
161
|
specification_version: 3
|
161
162
|
summary: ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick
|
metadata.gz.sig
CHANGED
Binary file
|