Module: ChunkyPNG::Canvas::DataUrlImporting
- Included in:
- ChunkyPNG::Canvas
- Defined in:
- lib/chunky_png/canvas/data_url_importing.rb
Overview
Methods to import a canvas from a PNG data URL.
Instance Method Summary collapse
-
#from_data_url(string) ⇒ Canvas
Imports a canvas from a PNG data URL.
Instance Method Details
#from_data_url(string) ⇒ Canvas
Imports a canvas from a PNG data URL.
12 13 14 15 16 17 18 |
# File 'lib/chunky_png/canvas/data_url_importing.rb', line 12 def from_data_url(string) if string =~ %r[^data:image/png;base64,((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)$] from_blob($1.unpack("m").first) else raise SignatureMismatch, "The string was not a properly formatted data URL for a PNG image." end end |