Skip to content

Commit

Permalink
changed get_mp_pic() to use magick rather than imagr when show_plot =…
Browse files Browse the repository at this point in the history
… TRUE
  • Loading branch information
martigso committed Oct 17, 2024
1 parent 1035d18 commit aa5796d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: stortingscrape
Type: Package
Title: Access Data from the Norwegian Parliament API
Version: 0.3.1
Version: 0.3.2
Authors@R: person(given = "Martin",
family = "Søyland",
email = "martin.soyland@stv.uio.no",
Expand All @@ -15,7 +15,7 @@ BugReports: https://github.com/martigso/stortingscrape/issues
Depends: R (>= 4.2.0)
Encoding: UTF-8
Imports: rvest, httr2, parallel, stringr
Suggests: imager, rmarkdown, knitr, pscl
Suggests: magick, rmarkdown, knitr, pscl
License: GPL (>= 3)
VignetteBuilder: knitr
RoxygenNote: 7.3.2
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# stortingscrape 0.3.2

- Major changes
* Changed `get_mp_pic()` to utilize the `magick` package instead if `imagr` when `show_plot = TRUE`

# stortingscrape 0.3.1

- Minor changes
Expand Down
10 changes: 5 additions & 5 deletions R/get_mp_pic.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ get_mp_pic <- function(mpid = NA, size = "middels",


if(is.na(destfile) == TRUE & show_plot == TRUE){
if(requireNamespace("imager") == FALSE) stop("Package 'imager' required for plotting images")
if(requireNamespace("magick") == FALSE) stop("Package 'magick' required for plotting images")

p <- imager::load.image(url)
plot(p, axes = FALSE)
p <- magick::image_read(url)
plot(p)
}

if(is.na(destfile) == TRUE & show_plot == FALSE){
Expand All @@ -87,8 +87,8 @@ get_mp_pic <- function(mpid = NA, size = "middels",

if(is.na(destfile) == FALSE & show_plot == TRUE){
download.file(url, destfile = destfile)
p <- imager::load.image(destfile)
plot(p, axes = FALSE)
p <- magick::image_read(url)
plot(p)
}

if(is.na(destfile) == FALSE & show_plot == FALSE){
Expand Down

0 comments on commit aa5796d

Please sign in to comment.