R/read-any-bitmap.R
image_type.Rd
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
image_type(source, Verbose = FALSE)
source | Path to file or connection |
---|---|
Verbose | Whether to write a message to console on failure (Default
|
character value corresponding to standard file extension of image
format (i.e. jpg, png, bmp, tif) or NA_character_
on failure.
jpegfile=system.file("img", "Rlogo.jpg", package="jpeg") image_type(jpegfile)#> [1] "jpg"jpeg_pretending_to_be_png=tempfile(fileext = '.png') file.copy(jpegfile, jpeg_pretending_to_be_png)#> [1] TRUEimage_type(jpeg_pretending_to_be_png)#> [1] "jpg"unlink(jpeg_pretending_to_be_png)