quick_magick 0.5.0 → 0.5.2
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.
Potentially problematic release.
This version of quick_magick might be problematic. Click here for more details.
- data/README +1 -1
- data/Rakefile +1 -1
- data/lib/quick_magick/image.rb +10 -3
- data/quick_magick.gemspec +2 -2
- data/test/image_test.rb +45 -1
- metadata +2 -2
data/README
CHANGED
@@ -23,7 +23,7 @@ These are some situation when QuickMagick will be useful for you:
|
|
23
23
|
|
24
24
|
== How to install
|
25
25
|
First, you should install ImageMagick (http://www.imagemagick.org/) on your machine.
|
26
|
-
Command
|
26
|
+
Command line tools of ImageMagick must be in your system path.
|
27
27
|
You can check this by running the command:
|
28
28
|
identify --version
|
29
29
|
Now to install QuickMagick just type at your command line:
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('quick_magick', '0.5.
|
5
|
+
Echoe.new('quick_magick', '0.5.2') do |p|
|
6
6
|
p.description = "QuickMagick allows you to access ImageMagick command line functions using Ruby interface."
|
7
7
|
p.url = "http://quickmagick.rubyforge.org/"
|
8
8
|
p.author = "Ahmed ElDawy"
|
data/lib/quick_magick/image.rb
CHANGED
@@ -29,7 +29,7 @@ module QuickMagick
|
|
29
29
|
images << Image.new("#{filename}[#{i.to_s}]", info_line)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
images.
|
32
|
+
images.each(&proc) if block_given?
|
33
33
|
return images
|
34
34
|
end
|
35
35
|
|
@@ -74,6 +74,7 @@ module QuickMagick
|
|
74
74
|
# append the given option, value pair to the settings of the current image
|
75
75
|
def append_to_settings(arg, value="")
|
76
76
|
@arguments << %Q<-#{arg} "#{value}" >
|
77
|
+
@last_is_draw = false
|
77
78
|
self
|
78
79
|
end
|
79
80
|
|
@@ -92,12 +93,13 @@ module QuickMagick
|
|
92
93
|
|
93
94
|
# append the given option, value pair to the args for the current image
|
94
95
|
def append_to_operators(arg, value="")
|
95
|
-
|
96
|
+
is_draw = (arg == 'draw')
|
97
|
+
if @last_is_draw && is_draw
|
96
98
|
@arguments.insert(@arguments.rindex('"'), " #{value}")
|
97
99
|
else
|
98
100
|
@arguments << %Q<-#{arg} "#{value}" >
|
99
101
|
end
|
100
|
-
@last_is_draw =
|
102
|
+
@last_is_draw = is_draw
|
101
103
|
self
|
102
104
|
end
|
103
105
|
|
@@ -351,6 +353,11 @@ module QuickMagick
|
|
351
353
|
def save(output_filename)
|
352
354
|
result = `convert #{command_line} "#{output_filename}" 2>&1`
|
353
355
|
if $?.success?
|
356
|
+
if @pseudo_image
|
357
|
+
# since it's been saved, convert it to normal image (not pseudo)
|
358
|
+
initialize(output_filename)
|
359
|
+
revert!
|
360
|
+
end
|
354
361
|
return result
|
355
362
|
else
|
356
363
|
error_message = <<-ERROR
|
data/quick_magick.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{quick_magick}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ahmed ElDawy"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-18}
|
10
10
|
s.description = %q{QuickMagick allows you to access ImageMagick command line functions using Ruby interface.}
|
11
11
|
s.email = %q{ahmed.eldawy@badrit.com}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/quick_magick/image.rb", "lib/quick_magick/image_list.rb", "lib/quick_magick.rb"]
|
data/test/image_test.rb
CHANGED
@@ -74,6 +74,23 @@ class ImageTest < Test::Unit::TestCase
|
|
74
74
|
File.delete(out_filename) if out_filename && File.exists?(out_filename)
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_read_with_initialize
|
78
|
+
i = QuickMagick::Image.read(@logo_filename) do |image|
|
79
|
+
image.resize("300x300!")
|
80
|
+
image.colors = 2
|
81
|
+
end.first
|
82
|
+
out_filename = File.join($base_dir, "imagemagick-resized.png")
|
83
|
+
File.delete out_filename if File.exists?(out_filename)
|
84
|
+
i.save(out_filename)
|
85
|
+
assert File.exists?(out_filename)
|
86
|
+
i2 = QuickMagick::Image.read(out_filename).first
|
87
|
+
assert_equal 300, i2.width
|
88
|
+
assert_equal 300, i2.height
|
89
|
+
ensure
|
90
|
+
# clean up
|
91
|
+
File.delete(out_filename) if out_filename && File.exists?(out_filename)
|
92
|
+
end
|
93
|
+
|
77
94
|
def test_crop_image
|
78
95
|
i = QuickMagick::Image.read(@logo_filename).first
|
79
96
|
i.crop("300x200+0+0")
|
@@ -150,8 +167,22 @@ class ImageTest < Test::Unit::TestCase
|
|
150
167
|
end
|
151
168
|
|
152
169
|
def test_line_and_circle
|
170
|
+
i = QuickMagick::Image.solid(100, 100)
|
171
|
+
i.draw_line(0,0,20,20)
|
172
|
+
i.draw_circle(30,30,20,20)
|
173
|
+
assert_equal %Q{ "(" -size "100x100" -draw " line 0,0 20,20 circle 30,30 20,20" "xc:" ")" }, i.command_line
|
174
|
+
out_filename = File.join($base_dir, "draw_test.gif")
|
175
|
+
i.save out_filename
|
176
|
+
ensure
|
177
|
+
# clean up
|
178
|
+
File.delete(out_filename) if out_filename && File.exists?(out_filename)
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_lines_with_colors
|
153
182
|
i = QuickMagick::Image.solid(100, 100, :white)
|
183
|
+
i.stroke = "red"
|
154
184
|
i.draw_line(0,0,20,20)
|
185
|
+
i.stroke = "blue"
|
155
186
|
i.draw_circle(30,30,20,20)
|
156
187
|
out_filename = File.join($base_dir, "draw_test.gif")
|
157
188
|
i.save out_filename
|
@@ -185,4 +216,17 @@ class ImageTest < Test::Unit::TestCase
|
|
185
216
|
assert_equal 640, i2.width
|
186
217
|
assert_equal 480, i2.height
|
187
218
|
end
|
188
|
-
|
219
|
+
|
220
|
+
def test_image_converted_from_pseudo_to_normal
|
221
|
+
i = QuickMagick::Image.solid(100, 100, :white)
|
222
|
+
i.stroke = "red"
|
223
|
+
i.draw_line(0,0,20,20)
|
224
|
+
out_filename = File.join($base_dir, "draw_test.gif")
|
225
|
+
assert_raises QuickMagick::QuickMagickError do
|
226
|
+
i.save!
|
227
|
+
end
|
228
|
+
i.save out_filename
|
229
|
+
# Now it's non pseudo
|
230
|
+
i.save!
|
231
|
+
end
|
232
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quick_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed ElDawy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-18 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|