Skip to content
/ EXIFr Public
forked from cmartin/EXIFr

EXIFr : Natively read EXIF tags from R

License

Notifications You must be signed in to change notification settings

brownag/EXIFr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EXIFr : Natively read EXIF tags from R

This package natively reads EXIF tags from digital (JPEG) images. It does not rely on any external libraries or binary executables. Values are returned as stored in the image file. EXIF read capability in native R will be useful for minimizing external, non-R dependencies.

NOTE: EXIFr is NOT the same package as exifr, which can be found on CRAN. exifr relies on either an external Perl library or compiled executable.

The primary purpose of this fork is to provide access to EXIF read functionality, especially for GPS tags, through the R environment. All of the "baseline" TIFF tags, plus those in the EXIF and GPS tag sets are available to be parsed. Any tags on the list found in the image will be returned by EXIFr::read_exif_data()

For some tags, the value is stored as a fraction or RATIONAL data type. For example ExposureTime is "1/3200" and not 0.0003125. Likewise for the degree, minute and second components of GPSLatitude and GPSLongitude for georeferenced images.

See the examples involving rational_to_numeric() and rationalDMS_to_decimal() helper functions for dealing with the RATIONAL tag type below.

To install this fork:

devtools::install_github("brownag/EXIFr")

To try the code with one of the example images :

library(EXIFr)

# To list all tags : 
image_path = system.file("extdata", "preview.jpg", package = "EXIFr")
read_exif_tags(image_path)
Make                     : Canon 
Model                    : Canon EOS DIGITAL REBEL XS 
Orientation              : 1 
XResolution              : 72/1 
YResolution              : 72/1 
ResolutionUnit           : 2 
DateTime                 : 2013:07:09 10:23:47 
ExposureTime             : 1/3200 
FNumber                  : 63/10 
ExposureProgram          : 3 
ISOSpeedRatings          : 800 
DateTimeOriginal         : 2013:07:09 10:23:47 
DateTimeDigitized        : 2013:07:09 10:23:47 
ApertureValue            : 43/8 
MaxApertureValue         : 5466/1427 
MeteringMode             : 5 
Flash                    : 16 
FocalLength              : 18/1 
SubsecTime               :  
SubsecTimeOriginal       :  
SubsecTimeDigitized      :  
ColorSpace               : 1 
PixelXDimension          : 100 
PixelYDimension          : 67 
FocalPlaneXResolution    : 215379/67 
FocalPlaneYResolution    : 32247/10 
FocalPlaneResolutionUnit : 2 
CustomRendered           : 0 
ExposureMode             : 0 
WhiteBalance             : 0 
SceneCaptureType         : 0 
# To view the value of a specific tag
read_exif_tags(image_path)[["ApertureValue"]]
[1] "43/8"

OR

rational_to_numeric(read_exif_tags(image_path)[["ApertureValue"]])
[1] 5.375

Another convenience function is for dealing with the 3-part RATIONAL result for GPSLatitude or GPSLongitude.

# read in sample georeferenced image input 
geo_image_path = system.file("extdata", "taiwan-jiufen.jpg", package = "EXIFr")
res <- read_exif_tags(geo_image_path)

# inspect EXIF result
latlng <- c(res[["GPSLatitude"]], res[["GPSLongitude"]])
print(latlng)

# convert rational Lat/Long degrees, minutes, seconds to decimal degrees
rationalDMS_to_decimal(latlng)
[1] "25/1 6/1 295339/10000"   "121/1 50/1 382141/10000"

[1]  25.1082 121.8439

Problems :

Please report any bugs or feature requests to the GitHub issue tracker.

Any questions about the original EXIFr package should be directed to to @cmartin : charles.martin1@uqtr.ca

Matters pertaining to maintenance of this EXIFr fork can contact @brownag via the issue tracker linked above.

More information

Info on EXIF tags, parsing JPEG files, and the the TIFF / EXIF standards can be found here:

Citation

If this code is useful to you, please cite the original package. @cmartin's robust framework was expanded on in this fork:

Charles A. Martin (2015). EXIFr: Natively read EXIF tags from R. R package version 0.0.0.9004. https://github.com/cmartin/EXIFr. DOI:10.5281/zenodo.34691

Packages

 
 
 

Languages

  • R 99.5%
  • Rebol 0.5%