lib/chunky_png/canvas/data_url_importing.rb
# Imports a canvas from a PNG data URL.
# @param [String] string The data URL string to load from.
# @return [Canvas] The imported canvas.
# @raise ChunkyPNG::SignatureMismatch if the provides string is not a properly
#    formatted PNG data URL (i.e. it should start with "data:image/png;base64,")
Imports a canvas from a PNG data URL.
Imports a canvas from a PNG data URL .
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
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
Imports a canvas from a PNG data URL.
Imports a canvas from a PNG data URL .
The imported canvas.
The imported canvas .
Canvas
:SignatureMismatch if the provides string is not a properly formatted PNG data URL
: SignatureMismatch if the provides string is not a properly formatted PNG data URL
string
<not_specific>
<not_specific>
string The data URL string to load from.
string The data URL string to load from .