npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@indraraj26/ion-camera

v1.0.0

Published

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.9.

Downloads

13

Readme

ion camera

ion camera provides directive and service to integrate cordova camera plugin on your Ionic application.

Demo application

Getting Started

Feature:

  • File URI will give you an blob
  • Directive and Service that manages everything for you out of box.

Installation

Before you install this package make sure that you are having below package installed on your project.

ionic cordova plugin add cordova-plugin-camera
npm install @ionic-native/camera

ionic cordova plugin add cordova-plugin-ionic-webview
npm install @ionic-native/ionic-webview
npm install @indraraj26/ion-camera

And then include it in your module (see app.module.ts):

import { IonCameraModule } from '@indraraj26/ion-camera';
// ...

@NgModule({
imports: [
 IonCameraModule.forRoot()
// ...
]
// ...
})
export class AppModule {}

If you are going to use this in feature module then include it in your feat.module.ts to use appIonCamera directive

import { IonCameraModule } from '@indraraj26/ion-camera';
// ...

@NgModule({
imports: [
 IonCameraModule
// ...
]
// ...
})
export class FeatModule {}

Usage

Breaking changes 1.0.0

Now output will be in object key and value.

  {result: blob, filePath: 'file://etc'}

Destination Type:

  • Destination type FILE_URI it will return blob (recommend you to use)
  • Destination type DATA_URL it will return base64 (default feature of cordova camera plugin and not recommended)

Directive:

You can place below directive on any element.

home.html

<ion-label [appIonCamera]="config" (cameraResult)="onCameraResult($event)">Open camera</ion-label>

home.ts

import { IonCameraService, IConfig } from '@indraraj26/ion-camera';

export class HomePage {
constructor(private camera: Camera, private _httpClient: HttpClient) {}
    public showImage: string;

    config: IConfig = {
    	quality: 50,
    	destinationType: this.camera.DestinationType.FILE_URI,
    	encodingType: this.camera.EncodingType.JPEG,
    	mediaType: this.camera.MediaType.PICTURE,
    	sourceType: this.camera.PictureSourceType.CAMERA,
    };

    onCameraResult(event: any) {
    console.log('returns blob', event);
    this.showImage = event.filePath;
    const formData = new FormData();
    formData.append('fileKey', event.result)
    this._httpClient.post('url', formData).subscribe()
  }

}

Service:

import { IonCameraService, IConfig } from '@indraraj26/ion-camera';

export class HomePage {
  public showImage: string;

	config: IConfig = {
		quality: 50,
		destinationType: this.camera.DestinationType.FILE_URI,
		encodingType: this.camera.EncodingType.JPEG,
		mediaType: this.camera.MediaType.PICTURE,
    sourceType: this.camera.PictureSourceType.CAMERA,
  };

  constructor(private _ionCameraService: IonCameraService, private _camera: Camera, private _httpClient: HttpClient) { }

  async openCameraThroughService() {
    const output = await this._ionCameraService.cameraAction(this.config);
    console.log(output, 'blob')
    this.showImage = output.filePath;
    const formData = new FormData();
    formData.append('fileKey', output.result)
    this._httpClient.post('url', formData).subscribe()
  }
}

Help Improve

Found a bug or an issue with this? Open a new issue here on GitHub.

Supported Version

Ionic 4 Ionic 5