Canvas2ImagePlugin icon indicating copy to clipboard operation
Canvas2ImagePlugin copied to clipboard

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

Open tiagocrt opened this issue 10 years ago • 15 comments

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

tiagocrt avatar Jun 04 '14 17:06 tiagocrt

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

chekst avatar Jun 17 '14 10:06 chekst

Here discribed how to do it http://stackoverflow.com/questions/4457904/iphone-how-do-i-get-the-file-path-of-an-image-saved-with-uiimagewritetosavedpho

chekst avatar Jun 18 '14 15:06 chekst

Any progress with this issue?

akozlov75 avatar Dec 02 '14 12:12 akozlov75

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.

nicolasgrolleau avatar Jan 14 '15 08:01 nicolasgrolleau

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

devgeeks avatar Feb 18 '15 21:02 devgeeks

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

antoniobrandao avatar May 15 '15 06:05 antoniobrandao

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

nicolasgrolleau avatar May 15 '15 07:05 nicolasgrolleau

@nicolasgrolleau Great! Does it work in WP8?

antoniobrandao avatar May 15 '15 07:05 antoniobrandao

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.

nicolasgrolleau avatar May 15 '15 20:05 nicolasgrolleau

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

antoniobrandao avatar May 16 '15 05:05 antoniobrandao

The pull request can be found in issue #45.

apeeters avatar Aug 11 '15 13:08 apeeters

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;
                ...
            };
        });
    } ...

apeeters avatar Aug 13 '15 10:08 apeeters

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?

markarupert avatar Sep 08 '15 01:09 markarupert

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: https://github.com/devgeeks/Canvas2ImagePlugin/commit/7cd3f03b8ccbac361b8def565877e934413aa110

After that it worked great. Thanks again!

joshgarwood avatar Feb 26 '16 03:02 joshgarwood

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

hoangtrungcs avatar Mar 18 '16 00:03 hoangtrungcs