@ionic-native/camera

  • Version 5.33.1
  • Published
  • 60.2 kB
  • 1 dependency
  • MIT license

Install

npm i @ionic-native/camera
yarn add @ionic-native/camera
pnpm add @ionic-native/camera

Overview

Ionic Native - Native plugins for ionic apps

Index

Variables

variable Camera

const Camera: CameraOriginal;

    Classes

    class CameraOriginal

    class CameraOriginal extends IonicNativePlugin {}
    • Camera camera Take a photo or capture video.

      Requires the Cordova plugin: cordova-plugin-camera. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).

      [Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add

      <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
      <string>You can take photos</string>
      </config-file>

      inside of the <platform name='ios> section

      import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
      constructor(private camera: Camera) { }
      ...
      const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
      }
      this.camera.getPicture(options).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64 (DATA_URL):
      let base64Image = 'data:image/jpeg;base64,' + imageData;
      }, (err) => {
      // Handle error
      });

      CameraOptions CameraPopoverOptions

    property DestinationType

    DestinationType: { DATA_URL: number; FILE_URI: number; NATIVE_URI: number };
    • Constant for possible destination types

    property Direction

    Direction: { BACK: number; FRONT: number };
    • Convenience constant

    property EncodingType

    EncodingType: { JPEG: number; PNG: number };
    • Convenience constant

    property MediaType

    MediaType: { PICTURE: number; VIDEO: number; ALLMEDIA: number };
    • Convenience constant

    property PictureSourceType

    PictureSourceType: {
    PHOTOLIBRARY: number;
    CAMERA: number;
    SAVEDPHOTOALBUM: number;
    };
    • Convenience constant

    property PopoverArrowDirection

    PopoverArrowDirection: {
    ARROW_UP: number;
    ARROW_DOWN: number;
    ARROW_LEFT: number;
    ARROW_RIGHT: number;
    ARROW_ANY: number;
    };
    • Convenience constant

    method cleanup

    cleanup: () => Promise<any>;
    • Remove intermediate image files that are kept in temporary storage after calling camera.getPicture. Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.

      Returns

      {Promise}

    method getPicture

    getPicture: (options?: CameraOptions) => Promise<any>;
    • Take a picture or video, or load one from the library.

      Parameter options

      Options that you want to pass to the camera. Encoding type, quality, etc. Platform-specific quirks are described in the [Cordova plugin docs](https://github.com/apache/cordova-plugin-camera#cameraoptions-errata-).

      Returns

      {Promise} Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.

    Interfaces

    interface CameraOptions

    interface CameraOptions {}

      property allowEdit

      allowEdit?: boolean;
      • Allow simple editing of image before selection.

      property cameraDirection

      cameraDirection?: number;
      • Choose the camera to use (front- or back-facing). Defined in Camera.Direction. Default is BACK. BACK: 0 FRONT: 1

      property correctOrientation

      correctOrientation?: boolean;
      • Rotate the image to correct for the orientation of the device during capture.

      property destinationType

      destinationType?: number;
      • Choose the format of the return value. Defined in Camera.DestinationType. Default is FILE_URI. DATA_URL : 0, Return image as base64-encoded string (DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible), FILE_URI : 1, Return image file URI, NATIVE_URI : 2 Return image native URI (e.g., assets-library:// on iOS or content:// on Android)

      property encodingType

      encodingType?: number;
      • Choose the returned image file's encoding. Defined in Camera.EncodingType. Default is JPEG JPEG : 0 Return JPEG encoded image PNG : 1 Return PNG encoded image

      property mediaType

      mediaType?: number;
      • Set the type of media to select from. Only works when PictureSourceType is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in Camera.MediaType PICTURE: 0 allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI ALLMEDIA : 2 allow selection from all media types

      property popoverOptions

      popoverOptions?: CameraPopoverOptions;
      • iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions.

      property quality

      quality?: number;
      • Picture quality in range 0-100. Default is 50

      property saveToPhotoAlbum

      saveToPhotoAlbum?: boolean;
      • Save the image to the photo album on the device after capture.

      property sourceType

      sourceType?: number;
      • Set the source of the picture. Defined in Camera.PictureSourceType. Default is CAMERA. PHOTOLIBRARY : 0, CAMERA : 1, SAVEDPHOTOALBUM : 2

      property targetHeight

      targetHeight?: number;
      • Height in pixels to scale image. Must be used with targetWidth. Aspect ratio remains constant.

      property targetWidth

      targetWidth?: number;
      • Width in pixels to scale image. Must be used with targetHeight. Aspect ratio remains constant.

      interface CameraPopoverOptions

      interface CameraPopoverOptions {}
      • iOS-only parameters that specify the anchor element location and arrow direction of the popover when selecting images from an iPad's library or album.

      property arrowDir

      arrowDir: number;
      • Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection Matches iOS UIPopoverArrowDirection constants. ARROW_UP : 1, ARROW_DOWN : 2, ARROW_LEFT : 4, ARROW_RIGHT : 8, ARROW_ANY : 15

      property height

      height: number;

        property width

        width: number;

          property x

          x: number;

            property y

            y: number;

              Enums

              enum DestinationType

              enum DestinationType {
              DATA_URL = 0,
              FILE_URL = 1,
              NATIVE_URI = 2,
              }

                member DATA_URL

                DATA_URL = 0

                  member FILE_URL

                  FILE_URL = 1

                    member NATIVE_URI

                    NATIVE_URI = 2

                      enum Direction

                      enum Direction {
                      BACK = 0,
                      FRONT = 1,
                      }

                        member BACK

                        BACK = 0

                          member FRONT

                          FRONT = 1

                            enum EncodingType

                            enum EncodingType {
                            JPEG = 0,
                            PNG = 1,
                            }

                              member JPEG

                              JPEG = 0

                                member PNG

                                PNG = 1

                                  enum MediaType

                                  enum MediaType {
                                  PICTURE = 0,
                                  VIDEO = 1,
                                  ALLMEDIA = 2,
                                  }

                                    member ALLMEDIA

                                    ALLMEDIA = 2

                                      member PICTURE

                                      PICTURE = 0

                                        member VIDEO

                                        VIDEO = 1

                                          enum PictureSourceType

                                          enum PictureSourceType {
                                          PHOTOLIBRARY = 0,
                                          CAMERA = 1,
                                          SAVEDPHOTOALBUM = 2,
                                          }

                                            member CAMERA

                                            CAMERA = 1

                                              member PHOTOLIBRARY

                                              PHOTOLIBRARY = 0

                                                member SAVEDPHOTOALBUM

                                                SAVEDPHOTOALBUM = 2

                                                  enum PopoverArrowDirection

                                                  enum PopoverArrowDirection {
                                                  ARROW_UP = 1,
                                                  ARROW_DOWN = 2,
                                                  ARROW_LEFT = 3,
                                                  ARROW_RIGHT = 4,
                                                  ARROW_ANY = 5,
                                                  }

                                                    member ARROW_ANY

                                                    ARROW_ANY = 5

                                                      member ARROW_DOWN

                                                      ARROW_DOWN = 2

                                                        member ARROW_LEFT

                                                        ARROW_LEFT = 3

                                                          member ARROW_RIGHT

                                                          ARROW_RIGHT = 4

                                                            member ARROW_UP

                                                            ARROW_UP = 1

                                                              Package Files (1)

                                                              Dependencies (1)

                                                              Dev Dependencies (0)

                                                              No dev dependencies.

                                                              Peer Dependencies (2)

                                                              Badge

                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic-native/camera.

                                                              • Markdown
                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic-native/camera)
                                                              • HTML
                                                                <a href="https://www.jsdocs.io/package/@ionic-native/camera"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>