R 从大量图像中提取元数据
我有一组非常大的行为观察研究的图像。我想把所有文件的文件名和每个文件的时间戳做成一个表格。因为所有文件都在同一个目录中,所以我可以使用R 从大量图像中提取元数据,r,R,我有一组非常大的行为观察研究的图像。我想把所有文件的文件名和每个文件的时间戳做成一个表格。因为所有文件都在同一个目录中,所以我可以使用fileSnapshot()轻松获取文件名和一些元数据。我希望得到一些简单的东西,比如: snapshot <- fileSnapshot('../data/raw/TMC') snap <- snapshot$info %>% rownames_to_column() %>% as.data.frame() %>% d
fileSnapshot()
轻松获取文件名和一些元数据。我希望得到一些简单的东西,比如:
snapshot <- fileSnapshot('../data/raw/TMC')
snap <- snapshot$info %>%
rownames_to_column() %>%
as.data.frame() %>%
dplyr::select(filename=rowname, timestamp=ctime)
快照%
as.data.frame()%>%
dplyr::select(filename=rowname,timestamp=ctime)
但是,由于这些文件是副本,而不是原始文件,ctime
变量显示文件是何时复制的,而不是照片是何时拍摄的。通过查看Windows资源管理器中的文件属性,我可以看到照片是何时拍摄的,因此我知道信息以某种方式与文件一起存储,但我不知道如何访问它
我意识到R可能不是这项工作的最佳工具,但我的工作流程的其余部分都是R,因此基于R的解决方案将是最好的。但我对其他选择持开放态度。提前谢谢 我认为您正在查找文件的EXIF数据,其中包含许多不同的元数据,包括创建日期 CRAN上有几个库可以提供帮助,但它们可能有点烦琐。它们似乎都通过调用ExifTools命令行程序来工作,它们都将为您提供安装程序。我发现最容易成为exiftoolr
install.packages(“exiftoolr”)
图书馆(“exiftoolr”)
library(tidyverse)#这纯粹是为了方便我将结果显示为一个tibble
安装_exiftool()
现在,在控制台中,您可以执行以下操作:
> exiftoolr::exif_read(path.expand("~/Rplot.jpeg"))
# A tibble: 1 x 24
SourceFile ExifToolVersion FileName Directory FileSize FileModifyDate FileAccessDate FileCreateDate
<chr> <dbl> <chr> <chr> <int> <chr> <chr> <chr>
1 //XGGC.SC~ 11.8 Rplot.j~ //XGGC.S~ 32908 2019:12:30 14~ 2019:12:30 14~ 2019:12:30 14~
# ... with 16 more variables: FilePermissions <int>, FileType <chr>, FileTypeExtension <chr>,
# MIMEType <chr>, JFIFVersion <chr>, ResolutionUnit <int>, XResolution <int>, YResolution <int>,
# ImageWidth <int>, ImageHeight <int>, EncodingProcess <int>, BitsPerSample <int>,
# ColorComponents <int>, YCbCrSubSampling <chr>, ImageSize <chr>, Megapixels <dbl>
EXIFTOOL::exif\U read(path.expand(“~/Rplot.jpeg”))
#一个tibble:1 x 24
SourceFile ExifToolVersion文件名目录文件大小文件修改日期文件访问日期文件创建日期
1//XGGC.SC~11.8 Rplot.j~//XGGC.S~32908 2019:12:30 14~2019:12:30 14~2019:12:30 14~
# ... 还有16个变量:FilePermissions、FileType、FileTypeExtension、,
#MIMEType、JFIVERSION、分辨率单元、X分辨率、Y分辨率、,
#ImageWidth、ImageHeight、编码过程、BitsPerSample、,
#彩色组件,YCbCrSubSampling,图像大小,百万像素
因此,通过编程,您可以这样做:
> exiftoolr::exif_read(path.expand("~/Rplot.jpeg"))
# A tibble: 1 x 24
SourceFile ExifToolVersion FileName Directory FileSize FileModifyDate FileAccessDate FileCreateDate
<chr> <dbl> <chr> <chr> <int> <chr> <chr> <chr>
1 //XGGC.SC~ 11.8 Rplot.j~ //XGGC.S~ 32908 2019:12:30 14~ 2019:12:30 14~ 2019:12:30 14~
# ... with 16 more variables: FilePermissions <int>, FileType <chr>, FileTypeExtension <chr>,
# MIMEType <chr>, JFIFVersion <chr>, ResolutionUnit <int>, XResolution <int>, YResolution <int>,
# ImageWidth <int>, ImageHeight <int>, EncodingProcess <int>, BitsPerSample <int>,
# ColorComponents <int>, YCbCrSubSampling <chr>, ImageSize <chr>, Megapixels <dbl>
my_dir文件已创建
#>1 ed_to_AAU_transfers.jpeg 2019:06:27 17:14:27+01:00
#>2 hist.jpeg 2019:12:30 09:14:36+00:00
#>3 hist2.jpeg 2019:12:30 09:16:34+00:00
#>4 LOS_plot_for_Kirsty.jpeg 2019:09:24 12:52:03+01:00
#>5 mysterybin.jpeg 2018:07:28 22:17:12+01:00
#>6 Rplot.jpeg 2019:12:30 14:25:07+00:00
#>7 w46plot.jpeg 2018:06:05 17:38:17+01:00
我认为您正在查找文件的EXIF数据,其中包含许多不同的元数据,包括创建日期
CRAN上有几个库可以提供帮助,但它们可能有点烦琐。它们似乎都通过调用ExifTools命令行程序来工作,它们都将为您提供安装程序。我发现最容易成为exiftoolr
install.packages(“exiftoolr”)
图书馆(“exiftoolr”)
library(tidyverse)#这纯粹是为了方便我将结果显示为一个tibble
安装_exiftool()
现在,在控制台中,您可以执行以下操作:
> exiftoolr::exif_read(path.expand("~/Rplot.jpeg"))
# A tibble: 1 x 24
SourceFile ExifToolVersion FileName Directory FileSize FileModifyDate FileAccessDate FileCreateDate
<chr> <dbl> <chr> <chr> <int> <chr> <chr> <chr>
1 //XGGC.SC~ 11.8 Rplot.j~ //XGGC.S~ 32908 2019:12:30 14~ 2019:12:30 14~ 2019:12:30 14~
# ... with 16 more variables: FilePermissions <int>, FileType <chr>, FileTypeExtension <chr>,
# MIMEType <chr>, JFIFVersion <chr>, ResolutionUnit <int>, XResolution <int>, YResolution <int>,
# ImageWidth <int>, ImageHeight <int>, EncodingProcess <int>, BitsPerSample <int>,
# ColorComponents <int>, YCbCrSubSampling <chr>, ImageSize <chr>, Megapixels <dbl>
EXIFTOOL::exif\U read(path.expand(“~/Rplot.jpeg”))
#一个tibble:1 x 24
SourceFile ExifToolVersion文件名目录文件大小文件修改日期文件访问日期文件创建日期
1//XGGC.SC~11.8 Rplot.j~//XGGC.S~32908 2019:12:30 14~2019:12:30 14~2019:12:30 14~
# ... 还有16个变量:FilePermissions、FileType、FileTypeExtension、,
#MIMEType、JFIVERSION、分辨率单元、X分辨率、Y分辨率、,
#ImageWidth、ImageHeight、编码过程、BitsPerSample、,
#彩色组件,YCbCrSubSampling,图像大小,百万像素
因此,通过编程,您可以这样做:
> exiftoolr::exif_read(path.expand("~/Rplot.jpeg"))
# A tibble: 1 x 24
SourceFile ExifToolVersion FileName Directory FileSize FileModifyDate FileAccessDate FileCreateDate
<chr> <dbl> <chr> <chr> <int> <chr> <chr> <chr>
1 //XGGC.SC~ 11.8 Rplot.j~ //XGGC.S~ 32908 2019:12:30 14~ 2019:12:30 14~ 2019:12:30 14~
# ... with 16 more variables: FilePermissions <int>, FileType <chr>, FileTypeExtension <chr>,
# MIMEType <chr>, JFIFVersion <chr>, ResolutionUnit <int>, XResolution <int>, YResolution <int>,
# ImageWidth <int>, ImageHeight <int>, EncodingProcess <int>, BitsPerSample <int>,
# ColorComponents <int>, YCbCrSubSampling <chr>, ImageSize <chr>, Megapixels <dbl>
my_dir文件已创建
#>1 ed_to_AAU_transfers.jpeg 2019:06:27 17:14:27+01:00
#>2 hist.jpeg 2019:12:30 09:14:36+00:00
#>3 hist2.jpeg 2019:12:30 09:16:34+00:00
#>4 LOS_plot_for_Kirsty.jpeg 2019:09:24 12:52:03+01:00
#>5 mysterybin.jpeg 2018:07:28 22:17:12+01:00
#>6 Rplot.jpeg 2019:12:30 14:25:07+00:00
#>7 w46plot.jpeg 2018:06:05 17:38:17+01:00
尝试使用file.info('../data/raw/TMC')
尝试使用file.info('../data/raw/TMC')