javascript - save image generated by canvas from video image not saving -


i used following code generate image form video canvas method , works fine , displays image form video

how can save image in server,

    <video>         <source src="1.mp4" type="video/mp4">     </video>     <canvas>     </canvas>     <img id="screenshot" />     <script>     var context = canvas.getcontext('2d');     context.fillrect(0, 0, w, h);     context.drawimage(video, 0, 0, w, h);     var dataurl = canvas.todataurl();     document.getelementbyid('screenshot').src = dataurl; 

script save image

function savecanvas('canvas','pat/' , '.jpg', options) {                     return task.spawn(function * () {                     var reader = new filereader;                             var blob = yield new promise(accept = > canvas.toblob(accept, type, options));                             reader.readasarraybuffer(blob);                             yield new promise(accept = > { reader.onloadend = accept });                             return yield os.file.writeatomic('pat/', new uint8array(reader.result),                             { tmppath: 'pat/' + '.tmp' });                     });                             }      </script> 

is there way save image file random name


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -