quick_magick 0.7.2 → 0.7.3

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/Manifest CHANGED
@@ -1,9 +1,10 @@
1
1
  Manifest
2
- README
2
+ README.rdoc
3
3
  Rakefile
4
4
  lib/quick_magick.rb
5
5
  lib/quick_magick/image.rb
6
6
  lib/quick_magick/image_list.rb
7
+ quick_magick.gemspec
7
8
  test/9.gif
8
9
  test/badfile.xxx
9
10
  test/image_list_test.rb
data/Rakefile CHANGED
@@ -2,8 +2,9 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('quick_magick', '0.7.2') do |p|
5
+ Echoe.new('quick_magick', '0.7.3') do |p|
6
6
  p.description = "QuickMagick allows you to access ImageMagick command line functions using Ruby interface."
7
+ p.summary = "A gem build by BadrIT to access ImageMagick command line functions easily and quickly"
7
8
  p.url = "http://quickmagick.rubyforge.org/"
8
9
  p.author = "Ahmed ElDawy"
9
10
  p.email = "ahmed.eldawy@badrit.com"
data/lib/quick_magick.rb CHANGED
@@ -150,12 +150,31 @@ module QuickMagick
150
150
 
151
151
  alias hsl_color hsla_color
152
152
 
153
- # Escapes possible special chracters in command line by surrounding it with double quotes
153
+ # Escapes possible special chracters in command line
154
+ # by surrounding it with double quotes
154
155
  def escape_commandline(str)
155
156
  str =~ /^(\w|\s|\.)*$/ ? str : "\"#{str}\""
156
157
  end
157
158
 
158
159
  alias c escape_commandline
160
+
161
+ # Execute a command line and returns its results when it suceeds
162
+ # When the command fails, it throws QuickMagick::QuickMagickError
163
+ def exec3(command)
164
+ error_file = Tempfile.new('error')
165
+ error_filepath = error_file.path
166
+ error_file.close
167
+ result = `#{command} 2>"#{error_filepath}"`
168
+ unless $?.success?
169
+ error_message = <<-ERROR
170
+ Error executing command: command
171
+ Result is: #{result}
172
+ Error is: #{File.read(error_filepath)}
173
+ ERROR
174
+ raise QuickMagick::QuickMagickError, error_message
175
+ end
176
+ result
177
+ end
159
178
  end
160
179
  end
161
180
 
@@ -62,26 +62,14 @@ module QuickMagick
62
62
 
63
63
  # returns info for an image using <code>identify</code> command
64
64
  def identify(filename)
65
- error_file = Tempfile.new('identify_error')
66
- result = `identify #{filename} 2>'#{error_file.path}'`
67
- unless $?.success?
68
- error_message = <<-ERROR
69
- Error executing command: identify #{filename}
70
- Result is: #{result}
71
- Error is: #{error_file.read}
72
- ERROR
73
- raise QuickMagick::QuickMagickError, error_message
74
- end
75
- result
76
- ensure
77
- error_file.close
65
+ QuickMagick.exec3 "identify #{QuickMagick.c filename}"
78
66
  end
79
67
 
80
68
  end
81
69
 
82
70
  # append the given option, value pair to the settings of the current image
83
71
  def append_to_settings(arg, value=nil)
84
- @arguments << %Q<-#{arg} #{QuickMagick::c value} >
72
+ @arguments << "-#{arg} #{QuickMagick.c value} "
85
73
  @last_is_draw = false
86
74
  self
87
75
  end
@@ -110,7 +98,7 @@ module QuickMagick
110
98
  if @last_is_draw && is_draw
111
99
  @arguments.insert(@arguments.rindex('"'), " #{value}")
112
100
  else
113
- @arguments << %Q<-#{arg} #{QuickMagick::c value} >
101
+ @arguments << %Q<-#{arg} #{QuickMagick.c value} >
114
102
  end
115
103
  @last_is_draw = is_draw
116
104
  self
@@ -222,7 +210,7 @@ module QuickMagick
222
210
 
223
211
  # The command line so far that will be used to convert or save the image
224
212
  def command_line
225
- %Q< "(" #{@arguments} #{QuickMagick::c(image_filename + (@pseudo_image ? "" : "[#{@index}]"))} ")" >
213
+ %Q< "(" #{@arguments} #{QuickMagick.c(image_filename + (@pseudo_image ? "" : "[#{@index}]"))} ")" >
226
214
  end
227
215
 
228
216
  # An information line about the image obtained using 'identify' command line
@@ -377,25 +365,13 @@ module QuickMagick
377
365
 
378
366
  # saves the current image to the given filename
379
367
  def save(output_filename)
380
- error_file = Tempfile.new('convert_error')
381
- result = `convert #{command_line} '#{output_filename}' 2>'#{error_file.path}'`
382
- if $?.success?
383
- if @pseudo_image
384
- # since it's been saved, convert it to normal image (not pseudo)
385
- initialize(output_filename)
386
- revert!
387
- end
388
- return result
389
- else
390
- error_message = <<-ERROR
391
- Error executing command: convert #{command_line} "#{output_filename}"
392
- Result is: #{result}
393
- Error is: #{error_file.read}
394
- ERROR
395
- raise QuickMagick::QuickMagickError, error_message
396
- end
397
- ensure
398
- error_file.close
368
+ result = QuickMagick.exec3 "convert #{command_line} #{QuickMagick.c output_filename}"
369
+ if @pseudo_image
370
+ # since it's been saved, convert it to normal image (not pseudo)
371
+ initialize(output_filename)
372
+ revert!
373
+ end
374
+ return result
399
375
  end
400
376
 
401
377
  alias write save
@@ -404,22 +380,10 @@ module QuickMagick
404
380
  # saves the current image overwriting the original image file
405
381
  def save!
406
382
  raise QuickMagick::QuickMagickError, "Cannot mogrify a pseudo image" if @pseudo_image
407
- error_file = Tempfile.new('mogrify_error')
408
- result = `mogrify #{command_line} 2>'#{error_file.path}'`
409
- if $?.success?
410
- # remove all operations to avoid duplicate operations
411
- revert!
412
- return result
413
- else
414
- error_message = <<-ERRORMSG
415
- Error executing command: mogrify #{command_line}
416
- Result is: #{result}
417
- Error is: #{error_file.read}
418
- ERRORMSG
419
- raise QuickMagick::QuickMagickError, error_message
420
- end
421
- ensure
422
- error_file.close if error_file
383
+ result = QuickMagick.exec3 "mogrify #{command_line}"
384
+ # remove all operations to avoid duplicate operations
385
+ revert!
386
+ return result
423
387
  end
424
388
 
425
389
  alias write! save!
@@ -481,20 +445,9 @@ module QuickMagick
481
445
  # WARNING: This is done through command line which is very slow.
482
446
  # It is not recommended at all to use this method for image processing for example.
483
447
  def get_pixel(x, y)
484
- error_file = Tempfile.new('identify_error')
485
- result = `identify -verbose -crop #{QuickMagick::geometry(1,1,x,y)} #{QuickMagick::c(image_filename)}[#{@index}] 2>'#{error_file.path}'`
486
- unless $?.success?
487
- error_message = <<-ERROR
488
- Error executing command: identify #{image_filename}
489
- Result is: #{result}
490
- Error is: #{error_file.read}
491
- ERROR
492
- raise QuickMagick::QuickMagickError, error_message
493
- end
448
+ result = QuickMagick.exec3("identify -verbose -crop #{QuickMagick::geometry(1,1,x,y)} #{QuickMagick.c image_filename}[#{@index}]")
494
449
  result =~ /Histogram:\s*\d+:\s*\(\s*(\d+),\s*(\d+),\s*(\d+)\)/
495
450
  return [$1.to_i, $2.to_i, $3.to_i]
496
- ensure
497
- error_file.close
498
451
  end
499
452
 
500
453
  # displays the current image as animated image
data/quick_magick.gemspec CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{quick_magick}
5
- s.version = "0.7.2"
5
+ s.version = "0.7.3"
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-01-30}
9
+ s.date = %q{2010-04-26}
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", "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", "quick_magick.gemspec"]
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"]
14
14
  s.homepage = %q{http://quickmagick.rubyforge.org/}
15
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.5}
19
- s.summary = %q{QuickMagick allows you to access ImageMagick command line functions using Ruby interface.}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{A gem build by BadrIT to access ImageMagick command line functions easily and quickly}
20
20
  s.test_files = ["test/image_test.rb", "test/image_list_test.rb", "test/test_magick.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_magick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 7
8
+ - 3
9
+ version: 0.7.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ahmed ElDawy
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-30 00:00:00 +02:00
17
+ date: 2010-04-26 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -31,6 +36,7 @@ files:
31
36
  - lib/quick_magick.rb
32
37
  - lib/quick_magick/image.rb
33
38
  - lib/quick_magick/image_list.rb
39
+ - quick_magick.gemspec
34
40
  - test/9.gif
35
41
  - test/badfile.xxx
36
42
  - test/image_list_test.rb
@@ -38,7 +44,6 @@ files:
38
44
  - test/multipage.tif
39
45
  - test/test_magick.rb
40
46
  - test/warnings.tiff
41
- - quick_magick.gemspec
42
47
  has_rdoc: true
43
48
  homepage: http://quickmagick.rubyforge.org/
44
49
  licenses: []
@@ -57,21 +62,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
62
  requirements:
58
63
  - - ">="
59
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
60
67
  version: "0"
61
- version:
62
68
  required_rubygems_version: !ruby/object:Gem::Requirement
63
69
  requirements:
64
70
  - - ">="
65
71
  - !ruby/object:Gem::Version
72
+ segments:
73
+ - 1
74
+ - 2
66
75
  version: "1.2"
67
- version:
68
76
  requirements: []
69
77
 
70
78
  rubyforge_project: quickmagick
71
- rubygems_version: 1.3.5
79
+ rubygems_version: 1.3.6
72
80
  signing_key:
73
81
  specification_version: 3
74
- summary: QuickMagick allows you to access ImageMagick command line functions using Ruby interface.
82
+ summary: A gem build by BadrIT to access ImageMagick command line functions easily and quickly
75
83
  test_files:
76
84
  - test/image_test.rb
77
85
  - test/image_list_test.rb