Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tested on ruby 1.8.4 and windows

  • Loading branch information...
commit 0f8aa10da12d1aac64550f5cc433c7d63cfaacd4 1 parent fb60598
Ahmed Eldawy authored
Showing with 20 additions and 4 deletions.
  1. +20 −4 lib/quick_magick.rb
24 lib/quick_magick.rb
View
@@ -1,9 +1,19 @@
+# Define quick magick error
+module QuickMagick
+ class QuickMagickError < RuntimeError; end
+end
+
# check if ImageMagick is installed
-status = `identify --version`
-raise QuickMagick::QuickMagickError("ImageMagick not installed") if status.empty?
+begin
+ x = `identify --version 2>&1`
+ raise(QuickMagick::QuickMagickError, "ImageMagick not installed") unless x.index('ImageMagick')
+rescue Errno::ENOENT
+ # For Windows machines
+ raise(QuickMagick::QuickMagickError, "ImageMagick not installed")
+end
module QuickMagick
- class QuickMagickError < RuntimeError; end
+ # Different geometry flags
PercentGeometry = "%"
AspectGeometry = "!"
LessGeometry = "<"
@@ -11,23 +21,29 @@ class QuickMagickError < RuntimeError; end
AreaGeometry = "@"
MinimumGeometry = "^"
+ # Command for solid color
SolidColor = "xc"
+ # Command for linear gradient
LinearGradient = "gradient"
+ # Command for radial gradient
RadialGradient = "radial-gradient"
+ # Different possible patterns
Patterns = %w{bricks checkboard circles crosshatch crosshatch30 crosshatch45 fishscales} +
(0..20).collect {|level| "gray#{level}" } +
%w{hexagons horizontal horizontalsaw hs_bdiagonal hs_cross hs_diagcross hs_fdiagonal hs_horizontal
hs_vertical left30 left45 leftshingle octagons right30 right45 rightshingle smallfishscales
vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw}
- # generate a random string of specified length
+ # Generate a random string of specified length.
+ # Used to generate random names for temp files
def self.random_string(length=10)
@@CHARS ||= ("a".."z").to_a + ("1".."9").to_a
Array.new(length, '').collect{@@CHARS[rand(@@CHARS.size)]}.join
end
end
+# For backward compatibility with ruby < 1.8.7
unless "".respond_to? :start_with?
class String
def start_with?(x)
Please sign in to comment.
Something went wrong with that request. Please try again.