Capacitor: [Features] Camera FILE results and options width/height

Created on 1 Mar 2018  路  3Comments  路  Source: ionic-team/capacitor

[X] I would to submit a feature requests

Current behavior

I gave a try to the Camera.getPhoto (https://capacitor.ionicframework.com/docs/apis/camera), really promising.

But in order to use it in my business app, I would need the features like width, height and result as FILE which I used in Cordova.

Would it be possible to include them in your roadmap?

* Features *

All these features are kind of important to me, specially because it allows me to handle a bit better the required memory (ram) of my app on mobile device (specially the FILE_URI, which is super important on all these Android devices).

  • width and height: maxWidth and maxHeight of the captured images

Cordova doc:

targetWidth | number | 聽 | Width in pixels to scale image. Must be used with聽targetHeight. Aspect ratio remains constant.

targetHeight | number | 聽 | Height in pixels to scale image. Must be used with聽targetWidth. Aspect ratio remains constant.

  • FILE result: An URI to a FILE which was created in a temp folder of the device instead of a result as base64

Cordova doc:

FILE_URI | number | 1 | Return file uri (content://media/external/images/media/2 for Android)
-- | -- | -- | --

P.S.:About FILE_URI, I think that it would be acceptable that PWA "fallback" on base64. Files on iOS and Android, base64 on PWA.

enhancement

Most helpful comment

Thanks for the request. Just added this feature to master and will release tomorrow. you can set width and/or height. If you set one but not the other, it does an aspect ratio scale to fit that dimension. Also, it now returns a file URI, but the Filesystem plugin needs to be updated to support those.

Cheers!

All 3 comments

Thanks for the request. Just added this feature to master and will release tomorrow. you can set width and/or height. If you set one but not the other, it does an aspect ratio scale to fit that dimension. Also, it now returns a file URI, but the Filesystem plugin needs to be updated to support those.

Cheers!

@mlynch awesome! I'll try to give a try in the next couple of days

@mlynch thx for adding width/height, so far looks good!

I didn't get what you meant with "it now returns a file URI, but the Filesystem plugin needs to be updated to support those". I tried to use CameraResultType.Uri but I also get a base64 results with this setting.

P.S.: The documentation https://capacitor.ionicframework.com/docs/apis/camera should be updated to reflect the CameraResultType change, respectively CameraResultType.Base64 instead of "base64". Should I do a PR somewhere to correct that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daniel-lucas-silva picture daniel-lucas-silva  路  3Comments

MatanYadaev picture MatanYadaev  路  3Comments

alexcroox picture alexcroox  路  3Comments

gnesher picture gnesher  路  3Comments

peterpeterparker picture peterpeterparker  路  3Comments