devgeeks/Canvas2ImagePlugin

(iOS) How to get the ImageURI of the saved image?

Opened this issue · 15 comments

Has some method to return the ImageURI?? I need this information to pass to FileTransfer

Hi i have same question.
For Android it return in success calback, but for iPhone success calback return just "Image saved"

Any progress with this issue?

I've made a fork implementing what's described in the above stackoverflow.
https://github.com/nicolasgrolleau/Canvas2ImagePlugin.git
I also made a pull request but I think the project's owner doesn't have much time for this project.

I am hoping to devote some time to this project soon. I'll look at your fork and pull requests as soon as I can. I really appreciate your work on this @nicolasgrolleau

@nicolasgrolleau how can we get the imageURI in your fork's version ?

Same as for the android version, it's passed to the success callback.

@nicolasgrolleau Great! Does it work in WP8?

I havent't patched the WP8 plufin in my fork (not using WP8 for the moment).
The WP8 plugin returns "Image saved: " + picture.Name
So you can use it like this and use javascript to remove "Image saved: " from the returned string.
It sure would be better to have same behaviour for all platforms.

Yeah, I really needed the full path to the picture. Thanks for the quick replies!

The pull request can be found in issue #45.

For those needing to access the file created:

The path returned by the code is a native uri like
assets-library://asset/asset.PNG?id=C68D47DF-711F-490C-87FD-BEF6172A71CE&ext=PNG. This native uri cannot be used in for example image tags since it is an unsupported url. To convert it to a file path, use this snippet:

canvas2ImagePlugin.saveImageDataToLibrary(
    function (nativeUri) {
        resolveLocalFileSystemURL(nativeUri, function (fileEntry) {
            fileEntry.file(function (file) {
                var result = file.localURL;
                ...
            };
        });
    } ...

I am taking the saved file and uploading it my server and then I want to remove it from the phone. The upload works great using the code above so I know I am getting the right path. But The file remove fails. Is this because you are not permitted to remove files from the gallery programatically?

Hi @nicolasgrolleau Thanks so much for continuing the work on this plugin! I was having the problem on iOS where the callback simply returned "image saved" and thought I would try your fork.

However, now anytime I try to call the saveImageDataToLibrary function, the app crashes completely.

Is there anything in particular that I need to do for this to work, other than simply installing the plugin?

Thanks again!

EDIT:

I discovered that I needed to merge with this commit: 7cd3f03

After that it worked great. Thanks again!

If i don't use the plugin Canvas2ImagePlugin, i can save canvas image to sd card with html5 and jquery mobile ? please tell me . thanks all