quick_magick 0.5.4 → 0.6.0
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 +3 -0
- data/Rakefile +1 -1
- data/lib/quick_magick.rb +1 -1
- data/lib/quick_magick/image.rb +19 -1
- data/quick_magick.gemspec +5 -6
- data/test/image_test.rb +30 -0
- metadata +7 -5
data/README
CHANGED
@@ -176,6 +176,9 @@ QuickMagick supports also ImageList s
|
|
176
176
|
i.draw_text(30, 30, "Hello world!", :rotate=>45)
|
177
177
|
i.save 'hello.jpg'
|
178
178
|
|
179
|
+
... you can then convert it to blob using
|
180
|
+
i.to_blob
|
181
|
+
|
179
182
|
For more information on drawing API visit:
|
180
183
|
http://www.imagemagick.org/Usage/draw/
|
181
184
|
|
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
|
+
Echoe.new('quick_magick', '0.6.0') 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.rb
CHANGED
@@ -56,7 +56,7 @@ module QuickMagick
|
|
56
56
|
vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw}
|
57
57
|
|
58
58
|
|
59
|
-
class <<self
|
59
|
+
class << self
|
60
60
|
# Generate a random string of specified length.
|
61
61
|
# Used to generate random names for temp files
|
62
62
|
def random_string(length=10)
|
data/lib/quick_magick/image.rb
CHANGED
@@ -3,7 +3,7 @@ require "tempfile"
|
|
3
3
|
module QuickMagick
|
4
4
|
|
5
5
|
class Image
|
6
|
-
class <<self
|
6
|
+
class << self
|
7
7
|
|
8
8
|
# create an array of images from the given blob data
|
9
9
|
def from_blob(blob, &proc)
|
@@ -392,6 +392,24 @@ module QuickMagick
|
|
392
392
|
|
393
393
|
alias write! save!
|
394
394
|
alias mogrify! save!
|
395
|
+
|
396
|
+
def to_blob
|
397
|
+
tmp_file = Tempfile.new(QuickMagick::random_string)
|
398
|
+
if command_line =~ /-format\s(\S+)\s/
|
399
|
+
# use format set up by user
|
400
|
+
blob_format = $1
|
401
|
+
elsif !@pseudo_image
|
402
|
+
# use original image format
|
403
|
+
blob_format = self.format
|
404
|
+
else
|
405
|
+
# default format is jpg
|
406
|
+
blob_format = 'jpg'
|
407
|
+
end
|
408
|
+
save "#{blob_format}:#{tmp_file.path}"
|
409
|
+
blob = nil
|
410
|
+
File.open(tmp_file.path, 'rb') { |f| blob = f.read}
|
411
|
+
blob
|
412
|
+
end
|
395
413
|
|
396
414
|
# image file format
|
397
415
|
def format
|
data/quick_magick.gemspec
CHANGED
@@ -2,27 +2,26 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{quick_magick}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.6.0"
|
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-
|
9
|
+
s.date = %q{2009-09-16}
|
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"]
|
13
13
|
s.files = ["README", "Rakefile", "lib/quick_magick/image.rb", "lib/quick_magick/image_list.rb", "lib/quick_magick.rb", "Manifest", "quick_magick.gemspec", "test/image_test.rb", "test/badfile.xxx", "test/multipage.tif", "test/image_list_test.rb", "test/test_magick.rb", "test/9.gif"]
|
14
|
-
s.has_rdoc = true
|
15
14
|
s.homepage = %q{http://quickmagick.rubyforge.org/}
|
16
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Quick_magick", "--main", "README"]
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Quick_magick", "--main", "README~"]
|
17
16
|
s.require_paths = ["lib"]
|
18
17
|
s.rubyforge_project = %q{quickmagick}
|
19
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
20
19
|
s.summary = %q{QuickMagick allows you to access ImageMagick command line functions using Ruby interface.}
|
21
20
|
s.test_files = ["test/image_test.rb", "test/image_list_test.rb", "test/test_magick.rb"]
|
22
21
|
|
23
22
|
if s.respond_to? :specification_version then
|
24
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version =
|
24
|
+
s.specification_version = 3
|
26
25
|
|
27
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
27
|
else
|
data/test/image_test.rb
CHANGED
@@ -228,6 +228,34 @@ class ImageTest < Test::Unit::TestCase
|
|
228
228
|
File.delete(out_filename) if out_filename && File.exists?(out_filename)
|
229
229
|
end
|
230
230
|
|
231
|
+
def test_to_blob_default_format
|
232
|
+
i = QuickMagick::Image.solid(100, 100)
|
233
|
+
i.draw_line(0,0,20,20)
|
234
|
+
i.draw_circle(30,30,20,20)
|
235
|
+
blob = i.to_blob
|
236
|
+
i2 = QuickMagick::Image.from_blob(blob).first
|
237
|
+
assert_equal 100, i2.width
|
238
|
+
assert_equal 100, i2.height
|
239
|
+
assert_equal 'JPEG', i2.format
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_to_blob_with_custom_format
|
243
|
+
i = QuickMagick::Image.solid(100, 100)
|
244
|
+
i.draw_line(0,0,20,20)
|
245
|
+
i.draw_circle(30,30,20,20)
|
246
|
+
i.format = 'gif'
|
247
|
+
blob = i.to_blob
|
248
|
+
i2 = QuickMagick::Image.from_blob(blob).first
|
249
|
+
assert_equal 'GIF', i2.format
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_to_blob_with_original_format
|
253
|
+
i = QuickMagick::Image.read(@logo_filename).first
|
254
|
+
blob = i.to_blob
|
255
|
+
i2 = QuickMagick::Image.from_blob(blob).first
|
256
|
+
assert_equal 'PNG', i2.format
|
257
|
+
end
|
258
|
+
|
231
259
|
def test_colors
|
232
260
|
assert_equal "#00ff00ff", QuickMagick::rgb_color(0, 255, 0)
|
233
261
|
assert_equal "#00007fff", QuickMagick::rgb_color(0, 0, 0.5)
|
@@ -252,6 +280,8 @@ class ImageTest < Test::Unit::TestCase
|
|
252
280
|
i2 = QuickMagick::Image.read(out_filename).first
|
253
281
|
assert_equal 640, i2.width
|
254
282
|
assert_equal 480, i2.height
|
283
|
+
ensure
|
284
|
+
File.delete out_filename if File.exists?(out_filename)
|
255
285
|
end
|
256
286
|
|
257
287
|
def test_image_converted_from_pseudo_to_normal
|
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.
|
4
|
+
version: 0.6.0
|
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-
|
12
|
+
date: 2009-09-16 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -40,6 +40,8 @@ files:
|
|
40
40
|
- test/9.gif
|
41
41
|
has_rdoc: true
|
42
42
|
homepage: http://quickmagick.rubyforge.org/
|
43
|
+
licenses: []
|
44
|
+
|
43
45
|
post_install_message:
|
44
46
|
rdoc_options:
|
45
47
|
- --line-numbers
|
@@ -47,7 +49,7 @@ rdoc_options:
|
|
47
49
|
- --title
|
48
50
|
- Quick_magick
|
49
51
|
- --main
|
50
|
-
- README
|
52
|
+
- README~
|
51
53
|
require_paths:
|
52
54
|
- lib
|
53
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -65,9 +67,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
67
|
requirements: []
|
66
68
|
|
67
69
|
rubyforge_project: quickmagick
|
68
|
-
rubygems_version: 1.3.
|
70
|
+
rubygems_version: 1.3.5
|
69
71
|
signing_key:
|
70
|
-
specification_version:
|
72
|
+
specification_version: 3
|
71
73
|
summary: QuickMagick allows you to access ImageMagick command line functions using Ruby interface.
|
72
74
|
test_files:
|
73
75
|
- test/image_test.rb
|