Module: ChunkyPNG::Canvas::DataUrlExporting

Included in:
ChunkyPNG::Canvas
Defined in:
lib/chunky_png/canvas/data_url_exporting.rb

Overview

Methods to export a canvas to a PNG data URL.

Instance Method Summary collapse

Instance Method Details

#to_data_urlString

Exports the canvas as a data url (e.g. data:image/png;base64,<data>) that can easily be used inline in CSS or HTML.

Returns:

  • (String)

    The canvas formatted as a data URL string.



10
11
12
# File 'lib/chunky_png/canvas/data_url_exporting.rb', line 10

def to_data_url
  ["data:image/png;base64,", to_blob].pack("A*m").delete("\n")
end