capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Camera giving me png when docs say it should be jpg

Open coffeymatt opened this issue 5 years ago • 1 comments

Description of the problem:

The docs say I should get a jpg back from capacitor:

https://capacitor.ionicframework.com/docs/apis/camera/

// The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl. dataUrl ?: string;

When testing in the browser, I'm getting a png (e.g. data:image/png;base64,iVBO...). I need consistent or controllable behaviour of the image format.

Affected platform

  • [ ] Android
  • [ ] iOS
  • [ ] electron
  • [x] web

OS of the development machine

  • [x] Windows
  • [ ] macOS
  • [ ] linux

Other information:

Capacitor version: 1.1.0

node version: 10.16.0

npm version: 6.9.0

Steps to reproduce:

Take a picture:

      const { Camera } = Plugins;

      const image = await Camera.getPhoto({
        quality: 90,
        allowEditing: false,
        resultType: CameraResultType.DataUrl,
        source: CameraSource.Prompt
      });

Put a breakpoint on the result, you'll see the data url is png.

coffeymatt avatar Sep 05 '19 11:09 coffeymatt

Yeah, that's only true for the native platforms, on web it returns a png, so docs should be updated.

To make it possible to return a jpeg on web, ionic-pwa-elements should be updated to accept other image type https://github.com/ionic-team/pwa-elements/blob/master/src/components/camera/imagecapture.ts#L135

jcesarmobile avatar Jan 14 '20 16:01 jcesarmobile

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Jun 02 '23 12:06 ionitron-bot[bot]