Skip to contents

Check if one or multiple file name entry is an image

Usage

is.image(x)

Arguments

x

vector entry

Value

a boolean value to indicate if entry is an image

Details

This current function tests if the extension of the file name provided belongs to any of the image extensions listed below
AI - Adobe Illustrator
BMP - Bitmap Image
CDR - Corel Draw Picture
CGM - Computer Graphics Metafile
CR2 - Canon Raw Version 2
CRW - Canon Raw
CUR - Cursor Image
DNG - Digital Negative
EPS - Encapsulated PostScript
FPX - FlashPix
GIF - Graphics Interchange Format
HEIC - High-Efficiency Image File Format
HEIF - High-Efficiency Image File Format
ICO - Icon Image
IMG - GEM Raster Graphics
JFIF - JPEG File Interchange Format
JPEG - Joint Photographic Experts Group
JPG - Joint Photographic Experts Group
MAC - MacPaint Image
NEF - Nikon Electronic Format
ORF - Olympus Raw Format
PCD - Photo CD
PCX - Paintbrush Bitmap Image
PNG - Portable Network Graphics
PSD - Adobe Photoshop Document
SR2 - Sony Raw Version 2
SVG - Scalable Vector Graphics
TIF - Tagged Image File
TIFF - Tagged Image File Format
WebP - Web Picture Format
WMF - Windows Metafile
WPG - WordPerfect Graphics

Examples

img.1 <- "fjk.jpg"
is.image(img.1)
#> [1] TRUE

img.0 <- "fjk.bbVG"
is.image(img.0)
#> [1] FALSE

img.2 <- "fjk.bmp"
is.image(img.2)
#> [1] TRUE

img.3 <- "fjk.SVG"
is.image(img.3)
#> [1] TRUE

# a vector of file names
v <- c("logo.png", "business process.pdf",
"front_cover.jpg", "intro.docx",
"financial_future.doc", "2022 buybacks.xlsx")

is.image(v)
#> [1]  TRUE FALSE  TRUE FALSE FALSE FALSE


# when the file name has no extension
# the function returns NA
v2 <- c("img2.jpg","northbound.xlsx","landimg",NA)
is.image(v2)
#> [1]  TRUE FALSE    NA    NA