Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Downloading Images from App to Gallery, plus Base64ToGallery issue

$
0
0

I want to download images from my Ionic app into my phone’s gallery (android and ios, but testing on android).

A simple example is using Ionic’s own Build your First App. I basically want to take those photos that are displayed, and selectively download them to my phone’s gallery. I have tried Canvas2ImagePlugin (could not get to import) and Base64ToGallery but have gotten neither to work properly.

What would be your approach to this? Thanks.

Here is my current approach with Base64ToGallery:

const download_photo = async () => {
  const base64Data = await base64FromPath(photoToDelete.webviewPath!);
  Base64ToGallery.base64ToGallery(base64Data, {
    prefix: "", // Not sure what this should be, already tried '_img', 'img_', 'data:image/jpeg;base64,'
    mediaScanner: true,
  }).then(
    (res) => console.log("Saved image to gallery ", res),
    (err) => console.log("Error saving image to gallery ", err)
  );
};
download_photo();

Console logging the Base64Data shows it as:
“data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1B…” etc, with some foward slashes throughout.

I get these 2 errors in android debugging using base64ToGallery:

  1. “D/skia: — Failed to create image decoder with message ‘unimplemented’”
  2. “Msg: Error saving image to gallery The image could not be decoded”

Here’s the github. My main working file is src/pages/tab2.tsx

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>