<commit_before>---
layout: "v2_fluid/docs_base"
version: "2.2.6"
versionHref: "/docs/v2/native"
path: ""
category: native
id: "camerapreview"
title: "CameraPreview"
header_sub_title: "Class in module "
doc: "CameraPreview"
docType: "class"
---







<h1 class="api-title">
  
  CameraPreview
  

  

  

</h1>

<a class="improve-v2-docs" href="http://github.com/driftyco/ionic-native/edit/master/src/plugins/camera-preview.ts#L14">
  Improve this doc
</a>



<!-- decorators -->


<pre><code>$ ionic plugin add cordova-plugin-camera-preview</code></pre>
<p>Repo:
  <a href="https://github.com/westonganger/cordova-plugin-camera-preview">
    https://github.com/westonganger/cordova-plugin-camera-preview
  </a>
</p>

<!-- description -->

<p>Showing camera preview in HTML</p>
<p>For more info, please see the <a href="https://github.com/westonganger/cordova-plugin-camera-preview">Cordova Camera Preview Plugin Docs</a>.</p>


<!-- @platforms tag -->
<h2>Supported platforms</h2>

<ul>
  <li>Android</li><li>iOS</li>
</ul>

<!-- @platforms tag end -->


<!-- @usage tag -->

<h2>Usage</h2>

<pre><code>import { CameraPreview } from &#39;ionic-native&#39;;

// camera options (Size and location)
let cameraRect: CameraPreviewRect = {
  x: 100,
  y: 100,
  width: 200,
  height: 200
};


// start camera
CameraPreview.startCamera(
  cameraRect, // position and size of preview
  &#39;front&#39;, // default camera
  true, // tape to take picture
  false, // disable drag
  true // send the preview to the back of the screen so we can add overlaying elements
);

// Set the handler to run every time we take a picture
CameraPreview.setOnPictureTakenHandler().subscribe((result) =&gt; {
  console.log(result);
  // do something with the result
});


// take a picture
CameraPreview.takePicture({
  maxWidth: 640,
  maxHeight: 640
});

// Switch camera
CameraPreview.switchCamera();

// set color effect to negative
CameraPreview.setColorEffect(&#39;negative&#39;);

// Stop the camera preview
CameraPreview.stopCamera();
</code></pre>



<commit_msg>Automated build of native docs driftyco/ionic-native@<PASSWORD><commit_after>---
layout: "v2_fluid/docs_base"
version: "2.2.6"
versionHref: "/docs/v2/native"
path: ""
category: native
id: "camerapreview"
title: "CameraPreview"
header_sub_title: "Class in module "
doc: "CameraPreview"
docType: "class"
---







<h1 class="api-title">
  
  CameraPreview
  

  

  

</h1>

<a class="improve-v2-docs" href="http://github.com/driftyco/ionic-native/edit/master/src/plugins/camera-preview.ts#L14">
  Improve this doc
</a>



<!-- decorators -->


<pre><code>$ ionic plugin add https://github.com/westonganger/cordova-plugin-camera-preview</code></pre>
<p>Repo:
  <a href="https://github.com/westonganger/cordova-plugin-camera-preview">
    https://github.com/westonganger/cordova-plugin-camera-preview
  </a>
</p>

<!-- description -->

<p>Showing camera preview in HTML</p>
<p>For more info, please see the <a href="https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview">Cordova Camera Preview Plugin Docs</a>.</p>


<!-- @platforms tag -->
<h2>Supported platforms</h2>

<ul>
  <li>Android</li><li>iOS</li>
</ul>

<!-- @platforms tag end -->


<!-- @usage tag -->

<h2>Usage</h2>

<pre><code>import { CameraPreview } from &#39;ionic-native&#39;;

// camera options (Size and location)
let cameraRect: CameraPreviewRect = {
  x: 100,
  y: 100,
  width: 200,
  height: 200
};


// start camera
CameraPreview.startCamera(
  cameraRect, // position and size of preview
  &#39;front&#39;, // default camera
  true, // tap to take picture
  false, // disable drag
  true // send the preview to the back of the screen so we can add overlaying elements
);

// Set the handler to run every time we take a picture
CameraPreview.setOnPictureTakenHandler().subscribe((result) =&gt; {
  console.log(result);
  // do something with the result
});


// take a picture
CameraPreview.takePicture({
  maxWidth: 640,
  maxHeight: 640
});

// Switch camera
CameraPreview.switchCamera();

// set color effect to negative
CameraPreview.setColorEffect(&#39;negative&#39;);

// Stop the camera preview
CameraPreview.stopCamera();
</code></pre>




{'fraction_non_alphanumeric': 0.16404387219837863, 'fraction_numerical': 0.020982355746304245, 'mean_word_length': 3.8329493087557602, 'pattern_counts': {'":': 0, '<': 78, '<?xml version=': 0, '>': 78, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2961471', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1407, 'n_words': 353}