Sha256: 89b8b0a5a1aa1998d37801800205da4f0e85d1799ac928affc8935e667d8dcfe

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require 'mini_magick'
module MiniMagickProcessor
  def image_to_tiff
    generate_uid
    tmp_file = Pathname.new(Dir::tmpdir).join("#{@uid}_#{@source.basename}.tif").to_s
    cat = MiniMagick::Image.open(@source.to_s)
    cat.format("tif")
    cat.crop("#{@w}x#{@h}+#{@x}+#{@y}") unless [@x, @y, @w, @h].compact == []
    cat.write tmp_file.to_s
    return tmp_file
  end

  def image_from_blob(blob)
    generate_uid
    tmp_file = Pathname.new(Dir::tmpdir).join("#{@uid}_#{@source.basename}.tif").to_s
    cat = MiniMagick::Image.read(blob)
    cat.format("tif")
    cat.crop("#{@w}x#{@h}+#{@x}+#{@y}") unless [@x, @y, @w, @h].compact == []
    cat.write tmp_file.to_s
    return tmp_file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtesseract-0.0.10 lib/processors/mini_magick.rb