I'm developing phonegap application and I need to save Image from url to the Device Photo Gallery.
I can't find at the Phonegap Api a way for doing it and Also I didn't find phonegap plugin for that.
I need it to work with Iphone & Android
Thanks a lot!
This can be done using phone gap file plugin:
Simplest approach
If you are ok with it being in the download's folder do the following
Install In-App browser plugin
Create a download button with
Not only will this download the image it will offer to open the image in the corresponding app or browser.
I'm currently working on cordova-plugin-photo-library.
It can save image that given by url (file:// or data:). Works on ios and android, jpeg/png/gif:
The latest version of Cordova (3.3+), the newer (1.0.0+) version of File uses filesystem URLs instead of the file path. So, to make the accepted answer work with the newer version in the FileSystemSuccess function change the line:
to:
Another easy way is to use the Cordova/Phonegap plugin Canvas2ImagePlugin. Install it and add the following function to your code which is based on getImageDataURL() by Raul Sanchez (Thanks!).
Use it like this:
I cleaned-up and wrapped the code suggested by Suhas above - the accepted answer in an angular service so that it can easily be used in other application. You can find the snipet here.
To use it, you include the script in app.js (and your index.html file) then: