1

"How to browse and upload an image in a shiny application" has been discussed before( How can I browse and upload an image in a shiny application?). But I want the code can be used both in IOS and Android cellphone systems. Android cellphone system works well, but the IOS system does not. The problem is the photo format "heic" of the IOS system not compatible with shiny even I accept the "heic" photo format in my code. Then I change the iPad photos format to jepg(https://www.blog.motifphotos.com/convert-ipad-photos-to-jpeg/), the "Photo Library"enter image description here option works, but the "Take photo" option will crash, which means the user can't take photos and upload them immediately. Any suggestions?

the shiny link: https://hydrowebtw.shinyapps.io/ipad_upload_test/

my code:

library(shiny)
library(base64enc)

options(shiny.maxRequestSize = 30*1024^2)

ui <- fluidPage(
  fileInput("upload", "Upload image",
            accept =  c('image/png', 'image/jpeg','image/jpg', 'image/heic')),
  uiOutput("image")
)

server <- function(input, output){
  
  base64 <- reactive({
    inFile <- input[["upload"]]
    if(!is.null(inFile)){
      dataURI(file = inFile$datapath, mime = c('image/png', 'image/jpeg','image/jpg', 'image/heic'))
    }
  })
  
  output[["image"]] <- renderUI({
    if(!is.null(base64())){
      tags$div(
        tags$img(src= base64(), width="100%"),
        style = "width: 400px;"
      )
    }
  })
}

shinyApp(ui, server)
Matthew
  • 21
  • 1
  • 1
  • 1
    The "Take Photo" button worked for me on iPadOS 15.1 (19B74) on iPad Pro (12.9-inch) (3rd generation). See screenshot here https://i.stack.imgur.com/CLFCA.jpg – Josh Gray MD Dec 06 '21 at 02:37
  • Thanks for Josh Gray's test. Now "Take Photo" button also works for me. Maybe I will test for a few days. – Matthew Dec 09 '21 at 07:31

0 Answers0