smartimage 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,19 @@
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
+
9
+ 0.0.3:
10
+
11
+ * JRuby 1.5.1 compatibility fixes
12
+
13
+ 0.0.2:
14
+
15
+ * Initial release
16
+
17
+ 0.0.1:
18
+
19
+ * Buggy stealth release
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.3
1
+ 0.0.4
@@ -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), options
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 = :jpg if format.to_s == 'jpeg'
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(@canvas, format.to_s, output_stream)
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,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartimage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
4
+ version: 0.0.4
11
5
  platform: ruby
12
6
  authors:
13
7
  - Tony Arcieri
@@ -15,57 +9,39 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2010-07-01 00:00:00 -06:00
12
+ date: 2010-07-09 00:00:00 -06:00
19
13
  default_executable:
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: imagesize
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 25
30
- segments:
31
- - 0
32
- - 1
33
- - 1
34
23
  version: 0.1.1
35
- type: :runtime
36
- version_requirements: *id001
24
+ version:
37
25
  - !ruby/object:Gem::Dependency
38
26
  name: rmagick
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
42
30
  requirements:
43
31
  - - ">="
44
32
  - !ruby/object:Gem::Version
45
- hash: 59
46
- segments:
47
- - 2
48
- - 12
49
- - 2
50
33
  version: 2.12.2
51
- type: :runtime
52
- version_requirements: *id002
34
+ version:
53
35
  - !ruby/object:Gem::Dependency
54
36
  name: rspec
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
58
40
  requirements:
59
41
  - - ">="
60
42
  - !ruby/object:Gem::Version
61
- hash: 13
62
- segments:
63
- - 1
64
- - 2
65
- - 9
66
43
  version: 1.2.9
67
- type: :development
68
- version_requirements: *id003
44
+ version:
69
45
  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"
70
46
  email: tony@medioh.com
71
47
  executables: []
@@ -78,6 +54,7 @@ extra_rdoc_files:
78
54
  files:
79
55
  - .document
80
56
  - .gitignore
57
+ - CHANGES
81
58
  - LICENSE
82
59
  - README.markdown
83
60
  - Rakefile
@@ -104,27 +81,21 @@ rdoc_options:
104
81
  require_paths:
105
82
  - lib
106
83
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
84
  requirements:
109
85
  - - ">="
110
86
  - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
113
- - 0
114
87
  version: "0"
88
+ version:
115
89
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
90
  requirements:
118
91
  - - ">="
119
92
  - !ruby/object:Gem::Version
120
- hash: 3
121
- segments:
122
- - 0
123
93
  version: "0"
94
+ version:
124
95
  requirements: []
125
96
 
126
97
  rubyforge_project:
127
- rubygems_version: 1.3.7
98
+ rubygems_version: 1.3.5
128
99
  signing_key:
129
100
  specification_version: 3
130
101
  summary: It's like a Swiss Army Knife for images, but one of those tiny ones you can keep on your keychain