Module: ChunkyPNG::Canvas::DataUrlImporting

### Home Classes Methods

### In Files

- lib/chunky_png/canvas/data_url_importing.rb

### Methods

- #from_data_url

### Files

- BENCHMARKING.rdoc
- CHANGELOG.rdoc
- CONTRIBUTING.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- ChunkyPNG
- ChunkyPNG::CRCMismatch
- ChunkyPNG::Canvas
- ChunkyPNG::Canvas::Adam7Interlacing
- ChunkyPNG::Canvas::DataUrlExporting
- ChunkyPNG::Canvas::DataUrlImporting
- ChunkyPNG::Canvas::Drawing
- ChunkyPNG::Canvas::Masking
- ChunkyPNG::Canvas::Operations
- ChunkyPNG::Canvas::PNGDecoding
- ChunkyPNG::Canvas::PNGEncoding
- ChunkyPNG::Canvas::Resampling
- ChunkyPNG::Canvas::StreamExporting
- ChunkyPNG::Canvas::StreamImporting
- ChunkyPNG::Chunk
- ChunkyPNG::Chunk::Base
- ChunkyPNG::Chunk::CompressedText
- ChunkyPNG::Chunk::End
- ChunkyPNG::Chunk::Generic
- ChunkyPNG::Chunk::Header
- ChunkyPNG::Chunk::ImageData
- ChunkyPNG::Chunk::InternationalText
- ChunkyPNG::Chunk::Palette
- ChunkyPNG::Chunk::Text
- ChunkyPNG::Chunk::Transparency
- ChunkyPNG::Color
- ChunkyPNG::Datastream
- ChunkyPNG::Dimension
- ChunkyPNG::Exception
- ChunkyPNG::ExpectationFailed
- ChunkyPNG::Image
- ChunkyPNG::NotSupported
- ChunkyPNG::OutOfBounds
- ChunkyPNG::Palette
- ChunkyPNG::Point
- ChunkyPNG::RMagick
- ChunkyPNG::SignatureMismatch
- ChunkyPNG::Vector
- Enumerable
- String

No matching classes.

# ChunkyPNG::Canvas::DataUrlImporting

Methods to import a canvas from a PNG data URL.

### Public Instance Methods

from_data_url(string) click to toggle source

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,")

    # File lib/chunky_png/canvas/data_url_importing.rb, line 12
    def from_data_url(string)
      if string =~ %[^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

[Validate]

Generated with the Darkfish Rdoc Generator 2.