Have anyone experienced issues when trying to display larger images at Shinyapps (>10 mb).
Works fine locally, but getting out of memory and loose connection all the time at shinyapps.
Thanks
Demo :
https://sundsoy.shinyapps.io/shinyapps_test/
See code below:
library(shinydashboard)
library(shiny)
library(shinycssloaders)
library(shinyWidgets)
library(dashboardthemes)
library(plotly)
library(BiocManager)
options(repos = BiocManager::repositories())
library(EBImage) # Read Image (png + jpeg)
library(pryr)
# UI
#################################################################################
options(shiny.maxRequestSize = 30*1024^2) # max 30 mb file size
options(expressions = 500000)
sidebar <- dashboardSidebar(
sidebarMenu(
fileInput( "file1", "Choose image File", accept = c(".jpg",".png") ),
menuItem( "test", tabName = "dashboard", icon = icon("dashboard"))
)
)
body <- dashboardBody(
shinyDashboardThemes( theme = "grey_dark" ),
tabItems(
tabItem(tabName = "dashboard",
fluidRow(
plotlyOutput("org_image")
)
)
)
)
ui <- dashboardPage(
dashboardHeader(title = "test"),
sidebar,
body
)
# SERVER
#################################################################################
server <- function(input, output, session) {
#--------------------------------------------------------------------------------
# Org image
#--------------------------------------------------------------------------------
output$org_image <- plotly::renderPlotly({
plot_ly(type="image",z=img()*255)
})
#--------------------------------------------------------------------------------
# Read image
#--------------------------------------------------------------------------------
img <- reactive({
inFile<-input$file1
if (is.null(inFile$datapath)){ }
else {
file <- inFile$datapath
img <- EBImage::readImage(file ) %>% EBImage::resize(h=250) %>% EBImage::rotate(270 )
print(pryr::object_size(img))
img
}
})
}
shinyApp(ui, server)