quick_magick 0.3.0 → 0.4.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 CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('quick_magick', '0.3.0') do |p|
5
+ Echoe.new('quick_magick', '0.4.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
@@ -1,9 +1,19 @@
1
+ # Define quick magick error
2
+ module QuickMagick
3
+ class QuickMagickError < RuntimeError; end
4
+ end
5
+
1
6
  # check if ImageMagick is installed
2
- status = `identify --version`
3
- raise QuickMagick::QuickMagickError "ImageMagick not installed" if status.empty?
7
+ begin
8
+ x = `identify --version 2>&1`
9
+ raise(QuickMagick::QuickMagickError, "ImageMagick not installed") unless x.index('ImageMagick')
10
+ rescue Errno::ENOENT
11
+ # For Windows machines
12
+ raise(QuickMagick::QuickMagickError, "ImageMagick not installed")
13
+ end
4
14
 
5
15
  module QuickMagick
6
- class QuickMagickError < RuntimeError; end
16
+ # Different geometry flags
7
17
  PercentGeometry = "%"
8
18
  AspectGeometry = "!"
9
19
  LessGeometry = "<"
@@ -11,22 +21,36 @@ module QuickMagick
11
21
  AreaGeometry = "@"
12
22
  MinimumGeometry = "^"
13
23
 
24
+ # Command for solid color
14
25
  SolidColor = "xc"
26
+ # Command for linear gradient
15
27
  LinearGradient = "gradient"
28
+ # Command for radial gradient
16
29
  RadialGradient = "radial-gradient"
17
30
 
31
+ # Different possible patterns
18
32
  Patterns = %w{bricks checkboard circles crosshatch crosshatch30 crosshatch45 fishscales} +
19
33
  (0..20).collect {|level| "gray#{level}" } +
20
34
  %w{hexagons horizontal horizontalsaw hs_bdiagonal hs_cross hs_diagcross hs_fdiagonal hs_horizontal
21
35
  hs_vertical left30 left45 leftshingle octagons right30 right45 rightshingle smallfishscales
22
36
  vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw}
23
37
 
24
- # generate a random string of specified length
38
+ # Generate a random string of specified length.
39
+ # Used to generate random names for temp files
25
40
  def self.random_string(length=10)
26
41
  @@CHARS ||= ("a".."z").to_a + ("1".."9").to_a
27
42
  Array.new(length, '').collect{@@CHARS[rand(@@CHARS.size)]}.join
28
43
  end
29
44
  end
30
45
 
46
+ # For backward compatibility with ruby < 1.8.7
47
+ unless "".respond_to? :start_with?
48
+ class String
49
+ def start_with?(x)
50
+ self.index(x) == 0
51
+ end
52
+ end
53
+ end
54
+
31
55
  require 'quick_magick/image'
32
56
  require 'quick_magick/image_list'
@@ -8,6 +8,7 @@ module QuickMagick
8
8
  # create an array of images from the given blob data
9
9
  def from_blob(blob, &proc)
10
10
  file = Tempfile.new(QuickMagick::random_string)
11
+ file.binmode
11
12
  file.write(blob)
12
13
  file.close
13
14
  self.read(file.path, &proc)
@@ -28,7 +29,7 @@ module QuickMagick
28
29
  images << Image.new("#{filename}[#{i.to_s}]", info_line)
29
30
  end
30
31
  end
31
- images.collect!(&proc)
32
+ images.collect!(&proc) if block_given?
32
33
  return images
33
34
  end
34
35
 
@@ -124,7 +125,7 @@ module QuickMagick
124
125
 
125
126
  # fills a rectangle with a solid color
126
127
  def floodfill(width, height=nil, x=nil, y=nil, flag=nil, color=nil)
127
- # TODO do a special method for floodfill
128
+ append_to_operators "floodfill", QuickMagick::Image.retrieve_geometry(width, height, x, y, flag), color
128
129
  end
129
130
 
130
131
  # methods that are called with (=)
@@ -363,10 +364,10 @@ module QuickMagick
363
364
  if $?.success?
364
365
  return result
365
366
  else
366
- error_message = <<-ERROR
367
+ error_message = <<-ERRORMSG
367
368
  Error executing command: mogrify #{command_line}
368
369
  Result is: #{result}
369
- ERROR
370
+ ERRORMSG
370
371
  raise QuickMagick::QuickMagickError, error_message
371
372
  end
372
373
  end
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.3.0"
5
+ s.version = "0.4.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-07-30}
9
+ s.date = %q{2009-08-05}
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"]
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.3.0
4
+ version: 0.4.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-07-30 00:00:00 +03:00
12
+ date: 2009-08-05 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15