Sha256: beb1c899d375fe5119c5f074c9dbf2e522f2c029f0f9b04b9a8b12c1a830564c

Contents?: true

Size: 794 Bytes

Versions: 16

Compression:

Stored size: 794 Bytes

Contents

description  'ImageMagick'
dependencies 'utils/shell', 'utils/semaphore'

class ImageMagick < Shell
  def self.semaphore
    @semaphore ||= Semaphore.new
  end

  def initialize
    if (`gm -version` rescue '').include?('GraphicsMagick')
      @prefix = 'gm'
    elsif !(`convert -version` rescue '').include?('ImageMagick')
      raise 'GraphicsMagick or ImageMagick not found'
    end
  end

  def label(text)
    convert('-pointsize', 16, '-background', 'transparent', "label:#{text}", 'PNG:-').run rescue nil
  end

  def method_missing(name, *args, &block)
    if %w(convert identify).include?(name.to_s)
      super(@prefix, name, *args, &block)
    else
      super
    end
  end

  def self.run(cmd, data)
    semaphore.synchronize { super }
  end
end

Olelo::ImageMagick = ImageMagick

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
olelo-0.9.15 plugins/utils/image_magick.rb
olelo-0.9.14 plugins/utils/image_magick.rb
olelo-0.9.13 plugins/utils/image_magick.rb
olelo-0.9.12 plugins/utils/image_magick.rb
olelo-0.9.11 plugins/utils/image_magick.rb
olelo-0.9.10 plugins/utils/image_magick.rb
olelo-0.9.9 plugins/utils/image_magick.rb
olelo-0.9.8 plugins/utils/image_magick.rb
olelo-0.9.7 plugins/utils/image_magick.rb
olelo-0.9.6 plugins/utils/image_magick.rb
olelo-0.9.5 plugins/utils/image_magick.rb
olelo-0.9.4 plugins/utils/image_magick.rb
olelo-0.9.3 plugins/utils/image_magick.rb
olelo-0.9.2 plugins/utils/image_magick.rb
olelo-0.9.1 plugins/utils/image_magick.rb
olelo-0.9.0 plugins/utils/image_magick.rb