smartimage 0.0.3-java → 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/Rakefile +0 -22
- data/VERSION +1 -1
- data/lib/smart_image.rb +5 -2
- data/lib/smart_image/java_canvas.rb +13 -1
- metadata +13 -28
data/CHANGES
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.0.4:
|
2
|
+
|
3
|
+
* Fixed bug in processing alpha channel of JRuby canvas objects when saving
|
4
|
+
.jpgs, causing color channel corruption.
|
5
|
+
|
6
|
+
* Fixed bug in SmartImage.thumbnail_file where images are always saved as .pngs
|
7
|
+
regardless of the specified file extension.
|
8
|
+
|
1
9
|
0.0.3:
|
2
10
|
|
3
11
|
* JRuby 1.5.1 compatibility fixes
|
data/Rakefile
CHANGED
@@ -54,25 +54,3 @@ Rake::RDocTask.new do |rdoc|
|
|
54
54
|
rdoc.rdoc_files.include('README*')
|
55
55
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
56
|
end
|
57
|
-
|
58
|
-
namespace :java do
|
59
|
-
desc 'Munge the Jeweler gemspec into a JRuby compatible one'
|
60
|
-
task :gemspec => 'rake:gemspec' do
|
61
|
-
gemspec = File.read('smartimage.gemspec')
|
62
|
-
|
63
|
-
# Remove the last end statement
|
64
|
-
gemspec.sub!(/end\s*\Z/m, '')
|
65
|
-
|
66
|
-
# Add the Java platform requirement
|
67
|
-
gemspec << " s.platform = %q{java}\n"
|
68
|
-
|
69
|
-
# Readd the end statement
|
70
|
-
gemspec << "end\n"
|
71
|
-
|
72
|
-
# Remove RMagic dependencies
|
73
|
-
gemspec = gemspec.split("\n").reject { |line| line["<rmagick>"] }.join("\n")
|
74
|
-
|
75
|
-
# Write the Java gemspec
|
76
|
-
File.open("smartimage-java.gemspec", "w") { |file| file << gemspec }
|
77
|
-
end
|
78
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/smart_image.rb
CHANGED
@@ -76,7 +76,7 @@ class SmartImage
|
|
76
76
|
:format => File.extname(output_path).sub(/^\./, '')
|
77
77
|
}.merge(options)
|
78
78
|
|
79
|
-
data = SmartImage.thumbnail File.read(input_path),
|
79
|
+
data = SmartImage.thumbnail File.read(input_path), opts
|
80
80
|
File.open(output_path, 'w') { |file| file << data }
|
81
81
|
end
|
82
82
|
|
@@ -179,7 +179,10 @@ class SmartImage
|
|
179
179
|
# just there to annoy you and make you wish it had more options.
|
180
180
|
def encode(format, options = {})
|
181
181
|
# Sorry .jpeg lovers, I'm one of you too but the standard is jpg
|
182
|
-
format =
|
182
|
+
format = 'jpg' if format.to_s == 'jpeg'
|
183
|
+
format = format.to_s
|
184
|
+
|
185
|
+
raise ArgumentError, "invalid format: #{format}" unless %w(jpg png gif).include?(format)
|
183
186
|
|
184
187
|
@canvas.encode format, options
|
185
188
|
end
|
@@ -10,6 +10,7 @@ class SmartImage
|
|
10
10
|
java_import java.io.ByteArrayOutputStream
|
11
11
|
|
12
12
|
def initialize(width, height)
|
13
|
+
@width, @height = width, height
|
13
14
|
@canvas = BufferedImage.new width, height, BufferedImage::TYPE_INT_ARGB
|
14
15
|
end
|
15
16
|
|
@@ -64,8 +65,19 @@ class SmartImage
|
|
64
65
|
|
65
66
|
# Encode the image to the given format
|
66
67
|
def encode(format, options = {})
|
68
|
+
case format
|
69
|
+
when 'jpg'
|
70
|
+
# If we're trying to save an JPEG, we need to convert it to RGB
|
71
|
+
canvas = BufferedImage.new @width, @height, BufferedImage::TYPE_INT_RGB
|
72
|
+
|
73
|
+
graphics = canvas.graphics
|
74
|
+
graphics.draw_image @canvas, 0, 0, @width, @height, nil
|
75
|
+
else
|
76
|
+
canvas = @canvas
|
77
|
+
end
|
78
|
+
|
67
79
|
output_stream = ByteArrayOutputStream.new
|
68
|
-
ImageIO.write(
|
80
|
+
ImageIO.write(canvas, format, output_stream)
|
69
81
|
String.from_java_bytes output_stream.to_byte_array
|
70
82
|
end
|
71
83
|
end
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
4
|
+
version: 0.0.4
|
10
5
|
platform: java
|
11
6
|
authors:
|
12
7
|
- Tony Arcieri
|
@@ -14,37 +9,29 @@ autorequire:
|
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
11
|
|
17
|
-
date: 2010-07-
|
12
|
+
date: 2010-07-09 00:00:00 -06:00
|
18
13
|
default_executable:
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: imagesize
|
22
|
-
|
23
|
-
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
- 1
|
30
|
-
- 1
|
31
23
|
version: 0.1.1
|
32
|
-
|
33
|
-
version_requirements: *id001
|
24
|
+
version:
|
34
25
|
- !ruby/object:Gem::Dependency
|
35
26
|
name: rspec
|
36
|
-
|
37
|
-
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
30
|
requirements:
|
39
31
|
- - ">="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 1
|
43
|
-
- 2
|
44
|
-
- 9
|
45
33
|
version: 1.2.9
|
46
|
-
|
47
|
-
version_requirements: *id002
|
34
|
+
version:
|
48
35
|
description: " SmartImage provides a cross-platform solution for image compositing that works on both MRI and JRuby.\n If using RMagick feels like swatting a fly with a nucler missile, and ImageScience just doesn't get \n you there, SmartImage is hopefully at that sweet spot in the middle\n"
|
49
36
|
email: tony@medioh.com
|
50
37
|
executables: []
|
@@ -87,20 +74,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
74
|
requirements:
|
88
75
|
- - ">="
|
89
76
|
- !ruby/object:Gem::Version
|
90
|
-
segments:
|
91
|
-
- 0
|
92
77
|
version: "0"
|
78
|
+
version:
|
93
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
81
|
- - ">="
|
96
82
|
- !ruby/object:Gem::Version
|
97
|
-
segments:
|
98
|
-
- 0
|
99
83
|
version: "0"
|
84
|
+
version:
|
100
85
|
requirements: []
|
101
86
|
|
102
87
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.3.
|
88
|
+
rubygems_version: 1.3.5
|
104
89
|
signing_key:
|
105
90
|
specification_version: 3
|
106
91
|
summary: It's like a Swiss Army Knife for images, but one of those tiny ones you can keep on your keychain
|