Sha256: 033a7fba987ab7611eb5bf7f311fb31917f2147f335f9c0a2b2db3b0ea5a1600

Contents?: true

Size: 515 Bytes

Versions: 9

Compression:

Stored size: 515 Bytes

Contents

require 'base64'

module Parade
  module Helpers

    module EncodeImage

      def image_path_to_base64
        $stderr.puts "Please install `rmagick` to allow images to be included in content"
        ''
      end

      if defined?(Magick)
        def image_path_to_base64(path)
          magick_image = Magick::Image.read(path).first
          data = Base64.encode64(magick_image.to_blob).gsub("\n",'').strip
          "data:image/#{magick_image.format};base64,#{data}"
        end
      end

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
parade-0.10.2 lib/parade/helpers/encode_image.rb
parade-0.10.1 lib/parade/helpers/encode_image.rb
parade-0.10.0 lib/parade/helpers/encode_image.rb
parade-0.9.2 lib/parade/helpers/encode_image.rb
parade-0.9.1 lib/parade/helpers/encode_image.rb
parade-0.9.0 lib/parade/helpers/encode_image.rb
parade-0.8.2 lib/parade/helpers/encode_image.rb
parade-0.8.1 lib/parade/helpers/encode_image.rb
parade-0.8.0 lib/parade/helpers/encode_image.rb