License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Title: | Simple Unified Interface to Read Bitmap Images (BMP,JPEG,PNG,TIFF) |
Description: | Identifies and reads Windows BMP, JPEG, PNG, and TIFF format bitmap images. Identification defaults to the use of the magic number embedded in the file rather than the file extension. Reading of JPEG and PNG image depends on libjpg and libpng libraries. See file INSTALL for details if necessary. |
Version: | 0.1.5 |
URL: | https://github.com/jefferis/readbitmap |
BugReports: | https://github.com/jefferis/readbitmap/issues |
SystemRequirements: | libjpeg, libpng |
Imports: | bmp, jpeg, png, tiff |
Suggests: | pixmap, testthat |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2018-06-27 11:45:09 UTC; jefferis |
Author: | Gregory Jefferis |
Maintainer: | Gregory Jefferis <jefferis@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2018-06-27 13:48:52 UTC |
readbitmap: read standard bitmap image formats
Description
The readbitmap package enables users to read the three main general purpose
bitmap image formats (jpeg, png, bmp) without having to specify the image
type directly. This is provided by a single function
read.bitmap
, which uses a second function
image_type
, which is also exported for users, to identify the
image type of a file using appropriate magic values encoded in the
first few bytes of the image header. Images can therefore have any file
extension.
See Also
Identify the type of an image using the magic value at the start of the file
Description
Currently works for png, jpeg, BMP, and tiff images. Will seek to start of file if passed a connection. For details of magic values for files, see e.g. http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files
Usage
image_type(source, Verbose = FALSE)
Arguments
source |
Path to file or connection |
Verbose |
Whether to write a message to console on failure (Default
|
Value
character value corresponding to standard file extension of image
format (i.e. jpg, png, bmp, tif) or NA_character_
on failure.
Examples
jpegfile=system.file("img", "Rlogo.jpg", package="jpeg")
image_type(jpegfile)
jpeg_pretending_to_be_png=tempfile(fileext = '.png')
file.copy(jpegfile, jpeg_pretending_to_be_png)
image_type(jpeg_pretending_to_be_png)
unlink(jpeg_pretending_to_be_png)
Read in a bitmap image in JPEG, PNG, BMP or TIFF format
Description
By default uses magic bytes at the start of the file to identify the image type (rather than the file extension). Currently uses readers in bmp, jpeg, png, and tiff packages.
Usage
read.bitmap(f, channel, IdentifyByExtension = FALSE, ...)
Arguments
f |
Path to image file |
channel |
Integer identifying channel to return for an RGB image |
IdentifyByExtension |
Identify by file extension only (Default FALSE) |
... |
Additional parameters passed to underlying image readers |
Value
Objects returned by readJPEG
,
readPNG
, read.bmp
, or
readTIFF
. See their documentation for details.
See Also
image_type
, readJPEG
,
readPNG
, read.bmp
,
readTIFF
Examples
img1=read.bitmap(system.file("img", "Rlogo.jpg", package="jpeg"))
str(img1)
img2 <- read.bitmap(system.file("img", "Rlogo.png", package="png"))
# nb the PNG image has an alpha channel
str(img2)