quick_magick 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of quick_magick might be problematic. Click here for more details.
- data/Rakefile +1 -1
- data/lib/quick_magick.rb +1 -1
- data/lib/quick_magick/image.rb +34 -2
- data/quick_magick.gemspec +7 -7
- data/test/image_list_test.rb +4 -4
- data/test/image_test.rb +9 -2
- data/test/test_quick_magick.rb +17 -0
- metadata +11 -7
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.8.0') do |p|
|
6
6
|
p.description = "QuickMagick allows you to access ImageMagick command line functions using Ruby interface."
|
7
7
|
p.summary = "A gem build by BadrIT to access ImageMagick command line functions easily and quickly"
|
8
8
|
p.url = "http://quickmagick.rubyforge.org/"
|
data/lib/quick_magick.rb
CHANGED
@@ -153,7 +153,7 @@ module QuickMagick
|
|
153
153
|
# Escapes possible special chracters in command line
|
154
154
|
# by surrounding it with double quotes
|
155
155
|
def escape_commandline(str)
|
156
|
-
str =~ /^(\w
|
156
|
+
str =~ /^(\w|\.)*$/ ? str : "\"#{str}\""
|
157
157
|
end
|
158
158
|
|
159
159
|
alias c escape_commandline
|
data/lib/quick_magick/image.rb
CHANGED
@@ -16,11 +16,11 @@ module QuickMagick
|
|
16
16
|
|
17
17
|
# create an array of images from the given file
|
18
18
|
def read(filename, &proc)
|
19
|
-
info = identify(
|
19
|
+
info = identify(filename)
|
20
20
|
info_lines = info.split(/[\r\n]/)
|
21
21
|
images = []
|
22
22
|
info_lines.each_with_index do |info_line, i|
|
23
|
-
images << Image.new(
|
23
|
+
images << Image.new(filename, i, info_line)
|
24
24
|
end
|
25
25
|
images.each(&proc) if block_given?
|
26
26
|
return images
|
@@ -449,6 +449,38 @@ module QuickMagick
|
|
449
449
|
result =~ /Histogram:\s*\d+:\s*\(\s*(\d+),\s*(\d+),\s*(\d+)\)/
|
450
450
|
return [$1.to_i, $2.to_i, $3.to_i]
|
451
451
|
end
|
452
|
+
|
453
|
+
# Returns details of the image as found by "identify -verbose" command
|
454
|
+
def details
|
455
|
+
str_details = QuickMagick.exec3("identify -verbose #{QuickMagick.c image_filename}[#@index]")
|
456
|
+
# This is something like breadcrumb for hashes visited at any time
|
457
|
+
hash_stack = []
|
458
|
+
# Current indentation. Used to infer nesting using indentation
|
459
|
+
current_indent = ""
|
460
|
+
# Last key inserted in the hash. Used to determine which key is the parent of a nested hash
|
461
|
+
last_key = nil
|
462
|
+
# Start with top level empty hash
|
463
|
+
hash_stack.push({})
|
464
|
+
str_details.each_line do |line|
|
465
|
+
key, value = line.split(":", 2)
|
466
|
+
key_indent = key[/^\s*/]
|
467
|
+
if key_indent.length < current_indent.length
|
468
|
+
# Must go one level up
|
469
|
+
hash_stack.pop
|
470
|
+
elsif key_indent.length > current_indent.length
|
471
|
+
# Must go one level deeper using last key
|
472
|
+
hash_stack.last[last_key] = {}
|
473
|
+
hash_stack.push hash_stack.last[last_key]
|
474
|
+
end
|
475
|
+
current_indent = key_indent
|
476
|
+
|
477
|
+
key = key.strip
|
478
|
+
value = value.strip
|
479
|
+
hash_stack.last[key] = value
|
480
|
+
last_key = key
|
481
|
+
end
|
482
|
+
hash_stack.first
|
483
|
+
end
|
452
484
|
|
453
485
|
# displays the current image as animated image
|
454
486
|
def animate
|
data/quick_magick.gemspec
CHANGED
@@ -2,28 +2,28 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{quick_magick}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.8.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{2010-
|
9
|
+
s.date = %q{2010-10-28}
|
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.rdoc", "lib/quick_magick.rb", "lib/quick_magick/image.rb", "lib/quick_magick/image_list.rb"]
|
13
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/quick_magick.rb", "lib/quick_magick/image.rb", "lib/quick_magick/image_list.rb", "quick_magick.gemspec", "test/9.gif", "test/badfile.xxx", "test/image_list_test.rb", "test/image_test.rb", "test/multipage.tif", "test/test_magick.rb", "test/warnings.tiff"]
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/quick_magick.rb", "lib/quick_magick/image.rb", "lib/quick_magick/image_list.rb", "quick_magick.gemspec", "test/9.gif", "test/badfile.xxx", "test/image_list_test.rb", "test/image_test.rb", "test/multipage.tif", "test/test_magick.rb", "test/warnings.tiff", "test/test_quick_magick.rb"]
|
14
14
|
s.homepage = %q{http://quickmagick.rubyforge.org/}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Quick_magick", "--main", "README.rdoc
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Quick_magick", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{quickmagick}
|
18
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
19
|
s.summary = %q{A gem build by BadrIT to access ImageMagick command line functions easily and quickly}
|
20
|
-
s.test_files = ["test/
|
20
|
+
s.test_files = ["test/test_quick_magick.rb", "test/image_test.rb", "test/test_magick.rb", "test/image_list_test.rb"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
24
|
s.specification_version = 3
|
25
25
|
|
26
|
-
if Gem::Version.new(Gem::
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
27
|
else
|
28
28
|
end
|
29
29
|
else
|
data/test/image_list_test.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'quick_magick'
|
3
|
-
require '
|
3
|
+
require 'fileutils'
|
4
4
|
|
5
5
|
$base_dir = File.dirname(File.expand_path(__FILE__))
|
6
6
|
|
7
7
|
class ImageTest < Test::Unit::TestCase
|
8
8
|
def setup
|
9
9
|
@logo_filename = File.join($base_dir, "imagemagick-logo.png")
|
10
|
-
`convert magick:logo #{@logo_filename}`
|
10
|
+
`convert magick:logo "#{@logo_filename}"`
|
11
11
|
@small_logo_filename = File.join($base_dir, "logo-small.jpg")
|
12
|
-
`convert magick:logo -resize 100x100! #{@small_logo_filename}`
|
12
|
+
`convert magick:logo -resize 100x100! "#{@small_logo_filename}"`
|
13
13
|
end
|
14
14
|
|
15
15
|
def teardown
|
@@ -111,4 +111,4 @@ class ImageTest < Test::Unit::TestCase
|
|
111
111
|
File.delete(out_filename1) if out_filename1 && File.exists?(out_filename1)
|
112
112
|
File.delete(out_filename2) if out_filename2 && File.exists?(out_filename2)
|
113
113
|
end
|
114
|
-
end
|
114
|
+
end
|
data/test/image_test.rb
CHANGED
@@ -7,9 +7,9 @@ class ImageTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def setup
|
9
9
|
@logo_filename = File.join($base_dir, "imagemagick-logo.png")
|
10
|
-
`convert magick:logo #{@logo_filename}`
|
10
|
+
`convert magick:logo "#{@logo_filename}"`
|
11
11
|
@small_logo_filename = File.join($base_dir, "logo-small.jpg")
|
12
|
-
`convert magick:logo -resize 100x100! #{@small_logo_filename}`
|
12
|
+
`convert magick:logo -resize 100x100! "#{@small_logo_filename}"`
|
13
13
|
end
|
14
14
|
|
15
15
|
def teardown
|
@@ -326,4 +326,11 @@ class ImageTest < Test::Unit::TestCase
|
|
326
326
|
image = QuickMagick::Image.read(image_filename)[1]
|
327
327
|
assert_equal [234,43,44], image.get_pixel(256,73)
|
328
328
|
end
|
329
|
+
|
330
|
+
def test_details
|
331
|
+
image_details = QuickMagick::Image.read(@logo_filename)[0].details
|
332
|
+
assert_equal Hash, image_details.class
|
333
|
+
assert_equal ["Image"], image_details.keys
|
334
|
+
assert_equal "228.364 (0.895545)", image_details["Image"]["Channel statistics"]["Red"]["mean"]
|
335
|
+
end
|
329
336
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'quick_magick'
|
3
|
+
|
4
|
+
$base_dir = File.dirname(File.expand_path(__FILE__))
|
5
|
+
|
6
|
+
class QuickMagickTest < Test::Unit::TestCase
|
7
|
+
def test_escape_commandline
|
8
|
+
[
|
9
|
+
["good_file_name.png", "good_file_name.png"],
|
10
|
+
["filename with spaces.png", '"filename with spaces.png"'],
|
11
|
+
["filename_with_$pec!als.jpg", '"filename_with_$pec!als.jpg"']
|
12
|
+
].each do |filename, escaped_filename|
|
13
|
+
assert_equal escaped_filename, QuickMagick::c(filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 8
|
8
|
+
- 0
|
9
|
+
version: 0.8.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ahmed ElDawy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-28 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- test/multipage.tif
|
45
45
|
- test/test_magick.rb
|
46
46
|
- test/warnings.tiff
|
47
|
+
- test/test_quick_magick.rb
|
47
48
|
has_rdoc: true
|
48
49
|
homepage: http://quickmagick.rubyforge.org/
|
49
50
|
licenses: []
|
@@ -55,10 +56,11 @@ rdoc_options:
|
|
55
56
|
- --title
|
56
57
|
- Quick_magick
|
57
58
|
- --main
|
58
|
-
- README.rdoc
|
59
|
+
- README.rdoc
|
59
60
|
require_paths:
|
60
61
|
- lib
|
61
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
62
64
|
requirements:
|
63
65
|
- - ">="
|
64
66
|
- !ruby/object:Gem::Version
|
@@ -66,6 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
68
|
- 0
|
67
69
|
version: "0"
|
68
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
69
72
|
requirements:
|
70
73
|
- - ">="
|
71
74
|
- !ruby/object:Gem::Version
|
@@ -76,11 +79,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
79
|
requirements: []
|
77
80
|
|
78
81
|
rubyforge_project: quickmagick
|
79
|
-
rubygems_version: 1.3.
|
82
|
+
rubygems_version: 1.3.7
|
80
83
|
signing_key:
|
81
84
|
specification_version: 3
|
82
85
|
summary: A gem build by BadrIT to access ImageMagick command line functions easily and quickly
|
83
86
|
test_files:
|
87
|
+
- test/test_quick_magick.rb
|
84
88
|
- test/image_test.rb
|
85
|
-
- test/image_list_test.rb
|
86
89
|
- test/test_magick.rb
|
90
|
+
- test/image_list_test.rb
|