Socket
Book a DemoInstallSign in
Socket

ionic-multi-camera

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic-multi-camera

Take multiple photos one after another

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

ionic-multi-camera

This package allows an Ionic App to take multiple photos in one go.

The "standard" Camera Plugin allows to take one photo per go. Whereas this package allows to take multiple photos in a row and confirm all of them at once.

Supports iOS and Android

npm Version npm Downloads

Example

Camera on iPhone X Editor on iPhone X

Install

First install the package from npm.

npm install --save ionic-multi-camera

To use this package you need to install the Cordova and Ionic Native Plugins it depends on.

# Install Ionic Native Plugins
npm install --save @ionic-native/core @ionic-native/camera-preview @ionic-native/device-motion @ionic-native/file @ionic-native/status-bar
# Install Cordova Plugins
ionic cordova plugin add https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git
ionic cordova plugin add cordova-plugin-device-motion
ionic cordova plugin add cordova-plugin-file
ionic cordova plugin add cordova-plugin-statusbar

The Cordova Plugin Camera Preview requires to add a NSCameraUsageDescription for iOS 10+. Add this to your config.xml.

<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
    <string>Take photos</string>
</edit-config>

Because the camera is placed in the background of the Webview you need to remove all backgrounds for the App. This means some extra work in the rest of your App to add a background. Add this to your app.scss.

ion-app, ion-content, .nav-decor {
  background-color: transparent !important;
}

The package allows to customize the used toolbar colors. Because of that you need to add a new color named camera to your variables.scss.

$colors: (
  camera: #000,
  ...
);

You need to import the IonicMultiCameraModule to your AppModule. Add this to your app.module.ts.

import { NgModule } from '@angular/core';
import { IonicMultiCameraModule } from 'ionic-multi-camera';

@NgModule({
  ...
  imports: [
    IonicMultiCameraModule.forRoot(),
    ...
  ],
  ...
})
export class AppModule {}

Usage

To use the library the function getPicture can be used and returns a Promise with an Array of Pictures.

import { Component } from '@angular/core';
import { IonicMultiCamera, Picture } from 'ionic-multi-camera';

@Component({
  selector: 'example-page',
  templateUrl: 'example.html'
})
export class Example {

  constructor(
    private camera: IonicMultiCamera
  ) {

  }

  public startCam(): void {
    this.camera.getPicture()
    .then((pictures: Array<Picture>) => {
      ...
    })
    .catch(err => {
      console.error(err);
    });
  }

}

If you would like to you can pass CameraPreviewPictureOptions directly to the camera. This allows to set the expected quality of the pictures.

It also accepts an object containing Translations for the camera. Otherwise defaults to English.

import { IonicMultiCamera, Picture, CameraTranslations } from 'ionic-multi-camera';
import { CameraPreviewPictureOptions } from '@ionic-native/camera-preview';
...

...
const pictureOptions: CameraPreviewPictureOptions = {
  quality: 80,
  width: 4096,
  height: 4096
};
const translations: CameraTranslations = {
  cancel: 'Cancel',
  finish: 'Finish',
  auto: 'AUTO',
  on: 'On',
  off: 'Off'
};
this.camera.getPicture(pictureOptions)
.then((pictures: Array<Picture>) => {
  ...
})
.catch(err => {
  console.error(err);
});
...

Keywords

ionic

FAQs

Package last updated on 16 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.