| readPng | R Documentation |
Read an image from a PNG file and convert the pixel data into an R array.
readPng(file) ## S3 method for class 'loder' print(x, ...)
file |
A character string giving the file name to read from. |
x |
An object of class |
... |
Additional arguments (which are ignored). |
The LodePNG library is used to read the PNG file at the specified path. LodePNG can handle a wide variety of subformats and bit depths, but the output of this function is currently standardised to an integer-mode array with 8-bit range, i.e. between 0 and 255. Attributes specifying the background colour, spatial resolution and/or aspect ratio are attached to the result if this information is stored with the image.
readPng returns an integer-mode array of class
"loder". The print method is called for its side-effect.
inspectPng to read only metadata from the file. In addition,
the readPNG function in the venerable png package offers
similar functionality to readPng, but relies on an external
installation of libpng. By contrast, loder includes the LodePNG
library.
path <- system.file("extdata", "pngsuite", package="loder")
image <- readPng(file.path(path, "basn6a08.png"))
print(image)
attributes(image)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.