filter images by their metadata

pdimg_filter(x, min_size = NULL, max_size = NULL)

Arguments

x

output from pdimg_images()

min_size, max_size

a file coerceable by fs::fs_bytes()

Value

same structure as pdimg_images()

Examples

x1 <- system.file("examples/Tierney2017JOSS.pdf", package="pdfimager")
x2 <- system.file("examples/vanGemert2018.pdf", package="pdfimager")
res <- pdimg_images(c(x1, x2))
res
#> [[1]]
#> # A tibble: 6 × 17
#>   path       page   num type  width height color  comp   bpc enc   interp object
#>   <chr>     <int> <int> <chr> <int>  <int> <chr> <int> <int> <chr> <chr>   <int>
#> 1 /var/fol…     1     0 image   650    249 rgb       3     8 image no          6
#> 2 /var/fol…     1     1 smask   650    249 gray      1     8 image no          6
#> 3 /var/fol…     2     2 image   650    249 rgb       3     8 image no          6
#> 4 /var/fol…     2     3 smask   650    249 gray      1     8 image no          6
#> 5 /var/fol…     2     4 image   672    480 icc       3     8 image no         41
#> 6 /var/fol…     2     5 smask   672    480 gray      1     8 image no         41
#> # ℹ 5 more variables: ID <int>, x.ppi <int>, y.ppi <int>, size <chr>,
#> #   ratio <chr>
#> 
#> [[2]]
#> # A tibble: 8 × 17
#>   path       page   num type  width height color  comp   bpc enc   interp object
#>   <chr>     <int> <int> <chr> <int>  <int> <chr> <int> <int> <chr> <chr>   <int>
#> 1 /var/fol…     1     0 image  1491    256 cmyk      4     8 jpeg  no        352
#> 2 /var/fol…     3     1 image   121     53 sep       1     8 jpeg  no         84
#> 3 /var/fol…     3     2 image   114     86 sep       1     8 jpeg  no         83
#> 4 /var/fol…     3     3 image   108     39 sep       1     8 jpeg  no         82
#> 5 /var/fol…     5     4 image    25    117 sep       1     8 image no        141
#> 6 /var/fol…     5     5 image    17     34 sep       1     8 image no        140
#> 7 /var/fol…     5     6 image    19     91 sep       1     8 image no        139
#> 8 /var/fol…     5     7 image    18     69 sep       1     8 image no        138
#> # ℹ 5 more variables: ID <int>, x.ppi <int>, y.ppi <int>, size <chr>,
#> #   ratio <chr>
#> 
res[[1]]$path
#> [1] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-000.ppm"
#> [2] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-001.ppm"
#> [3] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-002.ppm"
#> [4] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-003.ppm"
#> [5] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-004.ppm"
#> [6] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/Tierney2017JOSS/img-005.ppm"
res[[2]]$path
#> [1] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-000.ppm"
#> [2] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-001.ppm"
#> [3] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-002.ppm"
#> [4] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-003.ppm"
#> [5] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-004.ppm"
#> [6] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-005.ppm"
#> [7] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-006.ppm"
#> [8] "/var/folders/py/lcjn3y352g1106vf1rqk521r0000gn/T//RtmpQVrOR8/vanGemert2018/img-007.ppm"
pdimg_filter(x=res)
#> [[1]]
#> # A tibble: 1 × 17
#>   path       page   num type  width height color  comp   bpc enc   interp object
#>   <chr>     <int> <int> <chr> <int>  <int> <chr> <int> <int> <chr> <chr>   <int>
#> 1 /var/fol…     2     4 image   672    480 icc       3     8 image no         41
#> # ℹ 5 more variables: ID <int>, x.ppi <int>, y.ppi <int>, size <chr>,
#> #   ratio <chr>
#> 
#> [[2]]
#> # A tibble: 8 × 17
#>   path       page   num type  width height color  comp   bpc enc   interp object
#>   <chr>     <int> <int> <chr> <int>  <int> <chr> <int> <int> <chr> <chr>   <int>
#> 1 /var/fol…     1     0 image  1491    256 cmyk      4     8 jpeg  no        352
#> 2 /var/fol…     3     1 image   121     53 sep       1     8 jpeg  no         84
#> 3 /var/fol…     3     2 image   114     86 sep       1     8 jpeg  no         83
#> 4 /var/fol…     3     3 image   108     39 sep       1     8 jpeg  no         82
#> 5 /var/fol…     5     4 image    25    117 sep       1     8 image no        141
#> 6 /var/fol…     5     5 image    17     34 sep       1     8 image no        140
#> 7 /var/fol…     5     6 image    19     91 sep       1     8 image no        139
#> 8 /var/fol…     5     7 image    18     69 sep       1     8 image no        138
#> # ℹ 5 more variables: ID <int>, x.ppi <int>, y.ppi <int>, size <chr>,
#> #   ratio <chr>
#> 

x4 <- system.file("examples/Wunderlich2020.pdf", package="pdfimager")
res <- pdimg_images(x4)
pdimg_filter(res, min_size = "100K")
#> [[1]]
#> # A tibble: 1 × 17
#>   path       page   num type  width height color  comp   bpc enc   interp object
#>   <chr>     <int> <int> <chr> <int>  <int> <chr> <int> <int> <chr> <chr>   <int>
#> 1 /var/fol…     8     4 image  1294    755 rgb       3     8 image no        118
#> # ℹ 5 more variables: ID <int>, x.ppi <int>, y.ppi <int>, size <chr>,
#> #   ratio <chr>
#>