Crop uploads, save as jpeg in Shiny w/Croppie.js

I am trying to add a simple cropping feature to my Shiny app. The user should be able to upload an image, crop it, and save the cropped image to the www/ folder.

I have been able to render the image with croppie.js, but I am having trouble passing the base64 encoded image from Javascript to R with Shiny.onInputChange, and saving the image with R. The image file is saved, but it cannot be opened.

It sounds like the issue might be with the encoding of the image. Try using base64decode() in R to decode the base64 string before saving the image.