readPng {loder}R Documentation

Read a PNG file

Description

Read an image from a PNG file and convert the pixel data into an R array.

Usage

readPng(file)

## S3 method for class 'loder'
print(x, ...)

Arguments

file

A character string giving the file name to read from.

x

An object of class "loder".

...

Additional arguments (which are ignored).

Details

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.

Value

readPng returns an integer-mode array of class "loder". The print method is called for its side-effect.

See Also

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.

Examples

path <- system.file("extdata", "pngsuite", package="loder")
image <- readPng(file.path(path, "basn6a08.png"))
print(image)
attributes(image)


[Package loder version 0.2.1 Index]