android - Save Canvas to Device in Phonegap -
i've done lot of research , testing on this, getting compatibility/clarity issues right , left. hoping had clear solution this.
my phonegap build (3.1) application pulls images s3, adds overlay text them via html canvas, , needs saved user's phone on click action.
here relevant details:
- preferably saved location detectable gallery (android) or photos app (ios).
- i need work in android 2.3 , ios 6-7.
- i have composited version of image overlay text located on aws. happy downloading image device either composited image's url or canvas directly.
here of barriers:
- i keep getting "tainted canvas" security errors when trying "canvas.todataurl()", though set wildcard on s3's cors permissions used bucket.
- the "download" attribute seems unsupported in mobile browsers.
- i happy use phonegap's "filetransfer.download()" method, haven't been able figure out adequately acquire right file path on each device use in gallery/photos app
is there effective way done cross-platform?
as hate answer own question, found phonegap plugin called "canvas2image" perfect this: https://github.com/devgeeks/canvas2imageplugin
the description of pretty ambiguous in phonegap plugins directory, pretty saves image appropriate directory. takes success callback, error callback, , canvas element arguments. works in both ios , android, on unclear due phonegap plugins directory description.
window.canvas2imageplugin.saveimagedatatolibrary( function(msg){ ext.msg.alert('success!', 'the image saved photos gallery on device.'); }, function(err){ ext.msg.alert('aww, schucks!', 'there problem saving image device.'); }, document.queryselector('canvas') );
note: wouldn't recommend using document.queryselector
in sencha touch... it's clear reference.
speculative note: didn't further, appears may not great option if need subsequently link or open saved image.
Comments
Post a Comment