Save image file to photo gallery

I noticed this

<canvas id="myCanvas" width="165px" height="145px"></canvas>

so will the image stored in canvas also be 165x145?

For iOS, i used the SocialSharing plugin with ngCordova. You can call saveToPhotos() with the image or data Url.

For Android, I used the file plugin to write to the SD Card and then used the media scanner plugin which forces the gallery to index images on the SD card.


1 Like

My library cordova-plugin-photo-library could help:

cordova.plugins.photoLibrary.saveImage(url, 'My album', function () {}, function (err) {});

url can be file://… or can be data:…

is it possible to save images / transfer from local www to camera roll gallery ? but with specific name file

Hy guys, I am able to save image to photos directory of iphone. but not able to save to specefic album as defined in ionic native PhotoLibrary SaveImage…
my code is:
this.photoLibrary.saveImage(ulr, ‘MyApp’);
this function do store the image but not creating new ablum MyApp… Any body having this issue or resolved this issue… Please share… And also if someone know what options do we have while saving image

Save Image in device but with wrong name How can i fix that?

Give me your url code
Or all your code .

For Android you can go to:
then look for the function getImageFileName (it renames your photo with the actual date and a “index” number).

But in your case, you’ll maybe wanted to take a look on the saveMedia function also,
exactly this part of code: String extension = url.contains(".") ? url.substring(url.lastIndexOf(".")) : “”;

When the image url doesn’t have an extension right on the end, for example, images from Firebase Storage, it gets the extension wrong, then you should manipulate it for your needs.

And be aware that you have to “force” the bulid again so the changes take effect, just erase the android.json from platforms/android (I don’t know a better way to do this, sorry).

I don’t know if this is occurring also on iOS too, didn’t test it yet.

Hope it helps.

Ye i found that but it will safe with date name in library.
Here my solution.

    const fileTransfer = new Transfer();
    let validFileName = this.validateStr(fileName);
    let url = encodeURI(fileUrlBase + fileNameType);
    let targetPath = cordova.file.externalRootDirectory+ "VideVita/"  + validFileName +".mp4"; //this.cordova.file.dataDirectory
        console.log("Authorization request for camera use was " + (status == 
 cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));, targetPath, true).then((entry) => {
            console.log('download complete: ' + entry.toURL());
            env.isDownloadPopupVisible = true;
            cordova.plugins.MediaScannerPlugin.scanFile(targetPath,function () {

        }, (error) => {
            env.canDownloadFile = false;
            console.log("download error source " + error.source);
            console.log("download error target " +;
            console.log("upload error code" + error.code);
    }, function(error){
1 Like

@viskin i’ve read some of the documentation and i’m still not sure this is the tool i’m looking for.

Will this allow me to save an image in the phone gallery from an absolute url?

I’m looking for alternatives to cordova file-transfer which is now deprecated: