javascript - Convert Base64 to PNG/JPEG file in R -


i have seen process convert png file base64 work in post below convert r image base 64

i exact opposite of did. have base64 of image stored in variable "capimg" , want convert png or jpeg file. can me reverse engineer process.

is doable?

i have seen done using php below need r script same

<?php $data = urldecode($_post['imagedata']); list($type, $data) = explode(';', $data); list(, $data)      = explode(',', $data); $data = base64_decode($data); file_put_contents('image.png', $data); ?> 

in fact able decode base64 vector using base64enc package below y <- base64decode(capimg)

but not know how proceed further

this works me:

library(base64enc)  enc <- base64encode("images.jpg") conn <- file("w.bin","wb") writebin(enc, conn) close(conn)  inconn <- file("w.bin","rb") outconn <- file("img2.jpg","wb") base64decode(what=inconn, output=outconn) close(inconn) close(outconn) 

images.jpg courtesy of wikipedia accessed here


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -