【问题标题】:Ionic Capacitor: How can I change the type of ImagePicker to Base64?离子电容器:如何将 ImagePicker 的类型更改为 Base64?
【发布时间】:2022-01-22 21:02:05
【问题描述】:

我正在使用 Ionic(基于 Angular)和电容器插件(相机插件)构建应用程序。现在我希望用户可以从他们的图库中选择最多 5 张图像,所以我使用了电容器图像选择器 (https://capacitorjs.com/docs/apis/camera#pickimages)。它工作得很好,但是图像的类型是网络路径而不是 BASE64?!如何更改类型?我认为使用 GalleryImageOptions 是不可能的?

感谢您的回答!

【问题讨论】:

    标签: javascript angular typescript ionic-framework capacitor


    【解决方案1】:

    通过这种方式,您可以从图像选择器中获取 base64 网址。

    outputType: 1 是最重要的。类型 1 是 base64。

    getImages() {
        this.imgArray = [];
        this.imagePicker.getPictures({ maximumImagesCount: 10, quality: 50, height: 210, width: 210, outputType: 1 }).then(results => {
            if(results.length > 0) {
              for (let i = 0; i < results.length; i++) {
                this.imgArray.push(results[i]);
              }
              // this.getImageData();
            }
          },
          error => {
               .....
            });
      }
    

    【讨论】:

      猜你喜欢
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      相关资源
      最近更新 更多