Promises do not seem to work with magick

Hi

I have the following code which works perfectly:

---
title: "Example_no promises"
runtime: shiny
output:
    flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(magick)
```


UPLOAD 
================================================================

Column {.sidebar data-width=400}
----------------------------------------------------------------
``` {r echo = FALSE}
fileInput(inputId = "myimage", label = "My image", accept ="png", multiple = F,width = "500px",buttonLabel = "Upload Image")
vals <- reactiveValues()  

```



Column
-------------------------------------------------------------------

``` {r echo = FALSE}
imageOutput("image_uploaded")

temporary_file <- eventReactive(input$myimage,{
  input_myimage <- input$myimage$datapath
  initial_temporary_file <- file.path(tempdir(),"my_image.png")
  image_read(input_myimage) %>% image_write(path = initial_temporary_file,format = "png")
 })


output$image_uploaded <- renderImage({req(input$myimage)
  list(src = temporary_file())}, deleteFile = TRUE)

``` 

I just upload an image and it is displayed inside my shiny app. I want to add an expensive operation to that image in terms of image processing with magick library, but when I try to use future and promises libraries, it throws an error. My code with future and promises is below, but it throws the error *You cannot save or cache image objects between R sessions*:

---
title: "Example with promises"
runtime: shiny
output:
    flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(magick)
library(future)
library(promises)
library(devtools)
plan(multiprocess)
```


UPLOAD 
================================================================

Column {.sidebar data-width=400}
----------------------------------------------------------------
``` {r echo = FALSE}
fileInput(inputId = "myimage", label = "My image", accept ="png", multiple = F,width = "500px",buttonLabel = "Upload Image")
vals <- reactiveValues()  

```



Column
-------------------------------------------------------------------

``` {r echo = FALSE}
imageOutput("image_uploaded")

temporary_file <- eventReactive(input$myimage,{
  input_myimage <- input$myimage$datapath
  initial_temporary_file <- file.path(tempdir(),"my_image.png")
  future({image_read(input_myimage)}) %...>% image_write(path = initial_temporary_file,format = "png")
 })


output$image_uploaded <- renderImage({req(input$myimage)
  list(src = temporary_file())}, deleteFile = TRUE)

``` 

Does anybody know a solutions to this?

Thanks in advance

My session info:

- Session info ----------------------------------------------------------
 setting  value                       
 version  R version 3.5.3 (2019-03-11)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RTerm                       
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       Europe/Istanbul             
 date     2019-07-30                  

- Packages --------------------------------------------------------------
 package       * version date       lib source        
 assertthat      0.2.1   2019-03-21 [1] CRAN (R 3.5.3)
 backports       1.1.4   2019-04-10 [1] CRAN (R 3.5.3)
 callr           3.3.1   2019-07-18 [1] CRAN (R 3.5.3)
 cli             1.1.0   2019-03-19 [1] CRAN (R 3.5.3)
 codetools       0.2-16  2018-12-24 [2] CRAN (R 3.5.3)
 crayon          1.3.4   2017-09-16 [1] CRAN (R 3.5.3)
 desc            1.2.0   2018-05-01 [1] CRAN (R 3.5.3)
 devtools      * 2.1.0   2019-07-06 [1] CRAN (R 3.5.3)
 digest          0.6.20  2019-07-04 [1] CRAN (R 3.5.3)
 evaluate        0.14    2019-05-28 [1] CRAN (R 3.5.3)
 flexdashboard * 0.5.1.1 2018-06-29 [1] CRAN (R 3.5.3)
 fs              1.3.1   2019-05-06 [1] CRAN (R 3.5.3)
 future        * 1.14.0  2019-07-02 [1] CRAN (R 3.5.3)
 globals         0.12.4  2018-10-11 [1] CRAN (R 3.5.2)
 glue            1.3.1   2019-03-12 [1] CRAN (R 3.5.3)
 htmltools       0.3.6   2017-04-28 [1] CRAN (R 3.5.3)
 httpuv          1.5.1   2019-04-05 [1] CRAN (R 3.5.3)
 jsonlite        1.6     2018-12-07 [1] CRAN (R 3.5.3)
 knitr           1.23    2019-05-18 [1] CRAN (R 3.5.3)
 later           0.8.0   2019-02-11 [1] CRAN (R 3.5.3)
 listenv         0.7.0   2018-01-21 [1] CRAN (R 3.5.3)
 magick        * 2.0     2018-10-05 [1] CRAN (R 3.5.3)
 magrittr        1.5     2014-11-22 [1] CRAN (R 3.5.3)
 memoise         1.1.0   2017-04-21 [1] CRAN (R 3.5.3)
 mime            0.7     2019-06-11 [1] CRAN (R 3.5.3)
 pkgbuild        1.0.3   2019-03-20 [1] CRAN (R 3.5.3)
 pkgload         1.0.2   2018-10-29 [1] CRAN (R 3.5.3)
 prettyunits     1.0.2   2015-07-13 [1] CRAN (R 3.5.3)
 processx        3.4.1   2019-07-18 [1] CRAN (R 3.5.3)
 promises      * 1.0.1   2018-04-13 [1] CRAN (R 3.5.3)
 ps              1.3.0   2018-12-21 [1] CRAN (R 3.5.3)
 R6              2.4.0   2019-02-14 [1] CRAN (R 3.5.3)
 Rcpp            1.0.1   2019-03-17 [1] CRAN (R 3.5.3)
 remotes         2.1.0   2019-06-24 [1] CRAN (R 3.5.3)
 rlang           0.4.0   2019-06-25 [1] CRAN (R 3.5.3)
 rmarkdown       1.14    2019-07-12 [1] CRAN (R 3.5.3)
 rprojroot       1.3-2   2018-01-03 [1] CRAN (R 3.5.3)
 sessioninfo     1.1.1   2018-11-05 [1] CRAN (R 3.5.3)
 shiny         * 1.3.2   2019-04-22 [1] CRAN (R 3.5.3)
 stringi         1.4.3   2019-03-12 [1] CRAN (R 3.5.3)
 stringr         1.4.0   2019-02-10 [1] CRAN (R 3.5.3)
 testthat        2.1.1   2019-04-23 [1] CRAN (R 3.5.3)
 usethis       * 1.5.1   2019-07-04 [1] CRAN (R 3.5.3)
 withr           2.1.2   2018-03-15 [1] CRAN (R 3.5.3)
 xfun            0.8     2019-06-25 [1] CRAN (R 3.5.3)
 xtable          1.8-4   2019-04-21 [1] CRAN (R 3.5.3)
 yaml            2.2.0   2018-07-25 [1] CRAN (R 3.5.2)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.