Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
Cannot load the dataset split (in streaming mode) to extract the first rows.
Error code:   StreamingRowsError
Exception:    CastError
Message:      Couldn't cast
digest: string
kind: string
path: string
payload_sha3: string
prev: string
seq: int64
ts: timestamp[s]
all_passed: bool
benchmarks: list<item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: i (... 3044 chars omitted)
  child 0, item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code (... 3032 chars omitted)
      child 0, evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code_lines: int64, co (... 2961 chars omitted)
          child 0, ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>
              child 0, max_files: int64
              child 1, max_lines: int64
              child 2, min_lines: int64
          child 1, code_lines: int64
          child 2, command: string
          child 3, counts_command: string
          child 4, files_source: int64
          child 5, files_tests: int64
          child 6, files_total: int64
          child 7, method: string
          child 8, test_to_source_line_ratio: double
          child 9, total_lines: int64
          child 10, a_licences: list<item: string>
              child 0, item: string
          child 11, b_licences: list<item: string>
              child 0, item: string
          child 12, default_for_unknown_is_C: bool
          child 13, mismatches: struct<>
          child 14, observed: struct<agpl3: string, apache2: string, bsd3: string, commons_clause: string, garbage: st
...
ent: bool
              child 7, versioning: struct<detail: string, evidence_path: string, present: bool>
                  child 0, detail: string
                  child 1, evidence_path: string
                  child 2, present: bool
          child 62, criteria_missing: list<item: null>
              child 0, item: null
          child 63, criteria_satisfied: int64
          child 64, criteria_total: int64
          child 65, framework_controls_verified: int64
          child 66, ladder: string
          child 67, observed_level: int64
          child 68, source: string
          child 69, trL9_claimed: bool
          child 70, trL9_reason: string
      child 1, id: string
      child 2, ok: bool
      child 3, status: string
      child 4, title: string
root: string
platform: string
total: int64
sbom_written: bool
schema: string
version: string
method: struct<aggregate_rule: string, excluded: string, reproduce: string, thresholds_note: string>
  child 0, aggregate_rule: string
  child 1, excluded: string
  child 2, reproduce: string
  child 3, thresholds_note: string
python: string
failed: int64
failed_ids: list<item: null>
  child 0, item: null
passed: int64
source: struct<git: struct<head: string, url: string, branch: string, sha_verified_from: string>>
  child 0, git: struct<head: string, url: string, branch: string, sha_verified_from: string>
      child 0, head: string
      child 1, url: string
      child 2, branch: string
      child 3, sha_verified_from: string
to
{'all_passed': Value('bool'), 'benchmarks': List({'evidence': {'ceilings': {'max_files': Value('int64'), 'max_lines': Value('int64'), 'min_lines': Value('int64')}, 'code_lines': Value('int64'), 'command': Value('string'), 'counts_command': Value('string'), 'files_source': Value('int64'), 'files_tests': Value('int64'), 'files_total': Value('int64'), 'method': Value('string'), 'test_to_source_line_ratio': Value('float64'), 'total_lines': Value('int64'), 'a_licences': List(Value('string')), 'b_licences': List(Value('string')), 'default_for_unknown_is_C': Value('bool'), 'mismatches': {}, 'observed': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'only_class_A_may_relicense': Value('bool'), 'policy_probes': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'project_licence': {'LICENSE': Value('string'), '
...
Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'qualification_environment_pinned': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'reproducible_tests': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'rerunnable_verification': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'versioning': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}}, 'criteria_missing': List(Value('null')), 'criteria_satisfied': Value('int64'), 'criteria_total': Value('int64'), 'framework_controls_verified': Value('int64'), 'ladder': Value('string'), 'observed_level': Value('int64'), 'source': Value('string'), 'trL9_claimed': Value('bool'), 'trL9_reason': Value('string')}, 'id': Value('string'), 'ok': Value('bool'), 'status': Value('string'), 'title': Value('string')}), 'failed': Value('int64'), 'failed_ids': List(Value('null')), 'method': {'aggregate_rule': Value('string'), 'excluded': Value('string'), 'reproduce': Value('string'), 'thresholds_note': Value('string')}, 'passed': Value('int64'), 'platform': Value('string'), 'python': Value('string'), 'root': Value('string'), 'sbom_written': Value('bool'), 'schema': Value('string'), 'total': Value('int64'), 'version': Value('string'), 'source': {'git': {'head': Value('string'), 'url': Value('string'), 'branch': Value('string'), 'sha_verified_from': Value('string')}}}
because column names don't match
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/utils.py", line 147, in get_rows_or_raise
                  return get_rows(
                      dataset=dataset,
                  ...<4 lines>...
                      column_names=column_names,
                  )
                File "/src/libs/libcommon/src/libcommon/utils.py", line 272, in decorator
                  return func(*args, **kwargs)
                File "/src/services/worker/src/worker/utils.py", line 127, in get_rows
                  rows_plus_one = list(itertools.islice(safe_iter(ds, dataset=dataset), rows_max_number + 1))
                File "/src/services/worker/src/worker/utils.py", line 483, in safe_iter
                  yield from ds.decode(False) if ds.features else ds
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2951, in __iter__
                  for key, example in ex_iterable:
                                      ^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2461, in __iter__
                  for key, pa_table in self._iter_arrow():
                                       ~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2486, in _iter_arrow
                  for key, pa_table in self.ex_iterable._iter_arrow():
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 547, in _iter_arrow
                  for key, pa_table in iterator:
                                       ^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 430, in _iter_arrow
                  for key, pa_table in self.generate_tables_fn(**gen_kwags):
                                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 343, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2378, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2306, in cast_table_to_schema
                  raise CastError(
                  ...<3 lines>...
                  )
              datasets.table.CastError: Couldn't cast
              digest: string
              kind: string
              path: string
              payload_sha3: string
              prev: string
              seq: int64
              ts: timestamp[s]
              all_passed: bool
              benchmarks: list<item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: i (... 3044 chars omitted)
                child 0, item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code (... 3032 chars omitted)
                    child 0, evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code_lines: int64, co (... 2961 chars omitted)
                        child 0, ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>
                            child 0, max_files: int64
                            child 1, max_lines: int64
                            child 2, min_lines: int64
                        child 1, code_lines: int64
                        child 2, command: string
                        child 3, counts_command: string
                        child 4, files_source: int64
                        child 5, files_tests: int64
                        child 6, files_total: int64
                        child 7, method: string
                        child 8, test_to_source_line_ratio: double
                        child 9, total_lines: int64
                        child 10, a_licences: list<item: string>
                            child 0, item: string
                        child 11, b_licences: list<item: string>
                            child 0, item: string
                        child 12, default_for_unknown_is_C: bool
                        child 13, mismatches: struct<>
                        child 14, observed: struct<agpl3: string, apache2: string, bsd3: string, commons_clause: string, garbage: st
              ...
              ent: bool
                            child 7, versioning: struct<detail: string, evidence_path: string, present: bool>
                                child 0, detail: string
                                child 1, evidence_path: string
                                child 2, present: bool
                        child 62, criteria_missing: list<item: null>
                            child 0, item: null
                        child 63, criteria_satisfied: int64
                        child 64, criteria_total: int64
                        child 65, framework_controls_verified: int64
                        child 66, ladder: string
                        child 67, observed_level: int64
                        child 68, source: string
                        child 69, trL9_claimed: bool
                        child 70, trL9_reason: string
                    child 1, id: string
                    child 2, ok: bool
                    child 3, status: string
                    child 4, title: string
              root: string
              platform: string
              total: int64
              sbom_written: bool
              schema: string
              version: string
              method: struct<aggregate_rule: string, excluded: string, reproduce: string, thresholds_note: string>
                child 0, aggregate_rule: string
                child 1, excluded: string
                child 2, reproduce: string
                child 3, thresholds_note: string
              python: string
              failed: int64
              failed_ids: list<item: null>
                child 0, item: null
              passed: int64
              source: struct<git: struct<head: string, url: string, branch: string, sha_verified_from: string>>
                child 0, git: struct<head: string, url: string, branch: string, sha_verified_from: string>
                    child 0, head: string
                    child 1, url: string
                    child 2, branch: string
                    child 3, sha_verified_from: string
              to
              {'all_passed': Value('bool'), 'benchmarks': List({'evidence': {'ceilings': {'max_files': Value('int64'), 'max_lines': Value('int64'), 'min_lines': Value('int64')}, 'code_lines': Value('int64'), 'command': Value('string'), 'counts_command': Value('string'), 'files_source': Value('int64'), 'files_tests': Value('int64'), 'files_total': Value('int64'), 'method': Value('string'), 'test_to_source_line_ratio': Value('float64'), 'total_lines': Value('int64'), 'a_licences': List(Value('string')), 'b_licences': List(Value('string')), 'default_for_unknown_is_C': Value('bool'), 'mismatches': {}, 'observed': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'only_class_A_may_relicense': Value('bool'), 'policy_probes': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'project_licence': {'LICENSE': Value('string'), '
              ...
              Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'qualification_environment_pinned': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'reproducible_tests': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'rerunnable_verification': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'versioning': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}}, 'criteria_missing': List(Value('null')), 'criteria_satisfied': Value('int64'), 'criteria_total': Value('int64'), 'framework_controls_verified': Value('int64'), 'ladder': Value('string'), 'observed_level': Value('int64'), 'source': Value('string'), 'trL9_claimed': Value('bool'), 'trL9_reason': Value('string')}, 'id': Value('string'), 'ok': Value('bool'), 'status': Value('string'), 'title': Value('string')}), 'failed': Value('int64'), 'failed_ids': List(Value('null')), 'method': {'aggregate_rule': Value('string'), 'excluded': Value('string'), 'reproduce': Value('string'), 'thresholds_note': Value('string')}, 'passed': Value('int64'), 'platform': Value('string'), 'python': Value('string'), 'root': Value('string'), 'sbom_written': Value('bool'), 'schema': Value('string'), 'total': Value('int64'), 'version': Value('string'), 'source': {'git': {'head': Value('string'), 'url': Value('string'), 'branch': Value('string'), 'sha_verified_from': Value('string')}}}
              because column names don't match

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

CORDOVA_PLUGIN_CAMERA

licence offline-first audit checks

Governed Anticloud packaging of the upstream project CORDOVA_PLUGIN_CAMERA in category MOBILE. check results: see ISOLATED_LAB_RESULTS. Every number below traces to a named file + run stamp; nothing is borrowed from other projects.

Upstream: https://github.com/apache/cordova-plugin-camera · Upstream pin: acc35a89e7ac1276c3f4b238592c1167e4ce475b · Category: MOBILE · Vendor: Anticloud FZ LLE · Licence: Apache-2.0


What This Project Does


title: Camera description: Take pictures with the device camera.

cordova-plugin-camera

npm - Latest

GitHub GitHub - Android Workflow GitHub - Chrome Workflow GitHub - iOS Workflow GitHub - Lint GitHub - Release Audit Workflow

Depending on your use case, this plugin may be unnecessary.

We strongly recommend using the WebView's native <input type="file" accept="image/*" capture /> element before opting for this plugin.

The example above demonstrates how to capture an image. If you only need to select an existing image, simply remove the capture attribute.

For more information:

For advanced use cases, this plugin may be appropriate.

This plugin defines a global navigator.camera object, which provides an API for taking pictures and choosing images from the device's image library.

Although the object is attached to the global navigator object, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    console.log(navigator.camera);
}

Supported Platforms

  • Android
  • Browser
  • iOS

Installation

cordova plugin add cordova-plugin-camera

Plugin Variables

Plugin variables let you configure parts of a plugin and must be set during installation. To set these variables, append --variable {VARIABLE_NAME}={VALUE} to the cordova plugin add command for each variable. If you wish you change or remove any of the plugin variables, uninstall and reinstall with the updated variables.

  • ANDROIDX_CORE_VERSION

    Default: 1.6.+

    This variable allows you to configure the androidx.core:core dependency for this plugin only. Some plugins may include this dependency with hard-coded versions, so you can use this variable to try to match those versions and reduce conflicts.

    Example:

    cordova plugin add cordova-plugin-camera --variable ANDROIDX_CORE_VERSION=1.8.0
    

App Configuration

The following preferences can be set in the app's config.xml file to configure the plugin.

Android-Specific

Supporting saveToPhotoAlbum on Android 9 (API 28) & Lower

If you support Android 9 (API 28) and lower and need saveToPhotoAlbum, then this step is required.

If you support only Android 10 (API 29) and later, or do not need saveToPhotoAlbum, then skip this step.

Configuring the WRITE_EXTERNAL_STORAGE permission for Android 10 or later has no effect.

To declare the WRITE_EXTERNAL_STORAGE permission, add the following:

<config-file target="AndroidManifest.xml" parent="/*" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
</config-file>

iOS-Specific

Mandatory Usage Description

Since iOS 10, you must provide usage descriptions in the info.plist when accessing privacy-sensitive data.

The required keys depend on how you use the plugin and which iOS versions you support:

Key Description
NSCameraUsageDescription Required whenever the camera is used (e.g. Camera.PictureSourceType.CAMERA).
NSPhotoLibraryUsageDescription Required only when your app runs on iOS 13 or older and using as sourceType Camera.PictureSourceType.PHOTOLIBRARY. On iOS 14+ the plugin uses PHPicker for read-only access, which does not need this key.
NSPhotoLibraryAddUsageDescription Required when the plugin writes to the user's library (e.g. saveToPhotoAlbum=true).
NSLocationWhenInUseUsageDescription Required if CameraUsesGeolocation is set to true.

When the system prompts the user to allow access, this usage description string will be displayed as part of the permission dialog box. If you don't provide the required usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide a usage description.

To add these entries into the info.plist, you can use the edit-config tag in the config.xml like this:

<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
    <string>need camera access to take pictures</string>
</edit-config>

<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
    <string>need photo library access to get pictures from there</string>
</edit-config>

<edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
    <string>need photo library access to save pictures there</string>
</edit-config>

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>need location access to find things nearby</string>
</edit-config>

Preferences

  • CameraUsesGeolocation

    Default: false (boolean)

    Enables geolocation data in the EXIF header when capturing JPEG images. When set to true, the app will request for geolocation permissions .

    To set this preference, add the following:

    <preference name="CameraUsesGeolocation" value="false" />
    

API Reference


camera

camera.getPicture(successCallback, errorCallback, options)

Takes a photo using the camera, or retrieves a photo from the device's image gallery. The result is provided in the first parameter of the successCallback as a string.

As of v8.0.0, the result is formatted as URIs. The scheme will vary depending on settings and platform.

Platform Destination Type Format
Android FILE_URI An URI scheme such as file://... or content://...
DATA_URL Base 64 encoded with the proper data URI header
iOS FILE_URI file:// schemed paths
DATA_URL Base 64 encoded with the proper data URI header
Browser FILE_URI Not supported
DATA_URL Base 64 encoded with the proper data URI header

v7 and earlier versions, the return format is as follows:

Platform Destination Type Format
Android FILE_URI Raw file path (unprefixed)
DATA_URL Base 64 encoded, without the data: prefix
iOS FILE_URI file:// schemed paths
DATA_URL Base 64 encoded, without the data: prefix
Browser FILE_URI Not supported
DATA_URL Base 64 encoded, without the data: prefix

For this reason, upgrading to v8 is strongly recommended as it greatly streamlines the return data.

The camera.getPicture function opens the device's default camera application that allows users to snap pictures by default - this behavior occurs, when Camera.sourceType equals Camera.PictureSourceType.CAMERA. Once the user snaps the photo, the camera application closes and the application is restored.

If Camera.sourceType is Camera.PictureSourceType.PHOTOLIBRARY or Camera.PictureSourceType.SAVEDPHOTOALBUM, then a dialog displays that allows users to select an existing image.

The return value is sent to the cameraSuccess callback function, in one of the following formats, depending on the specified cameraOptions. You can do whatever you want with content:

  • Render the content in an <img> or <video> tag
  • Copy the data to a persistent location
  • Post the data to a remote server

NOTE: Photo resolution on newer devices is quite good. Photos selected from the device's gallery are not downscaled to a lower quality, even if a quality parameter is specified. To avoid common memory problems, set Camera.destinationType to FILE_URI rather than DATA_URL.

FILE_URI Usage

When FILE_URI is used, the returned path is not directly usable. The file path needs to be resolved into a DOM-usable URL using the Cordova File Plugin.

Additionally, the file URIs returned is a temporary read access grant. The OS reserves the right to revoke permission to access the resource, which typically occurs after the app has been closed. For images captured using the camera, the image is stored in a temporary location which can be cleared at any time, usually after the app exits. It's the application's decision to decide how the content should be used depending on their use cases.

For persistent access to the content, the resource should be copied to your app's storage container. An example use case is an app allowing an user to select a profile picture from their gallery or camera. The application will need consistent access to that resource, so it's not suitable to retain the temporary access path. So the appplication should copy the resource to a persistent location.

For use cases that involve temporary use, it is valid and safe to use the temporary file path to display the content. An example of this could be an image editing application, rendering the data into a canvas.

NOTE: The returned schemes is an implementation detail. Do not assume that it will always be a file:// URI.

Supported Platforms

  • Android
  • Browser
  • iOS

More examples here. Quirks here.

Kind: static method of camera

Param Type Description
successCallback onSuccess
errorCallback onError
options CameraOptions CameraOptions

Example

navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);

camera.stop()

Closes the active camera or photo library picker UI.

Supported Platforms

  • Android
  • iOS

Kind: static method of camera Example

navigator.camera.stop(onSuccess, onFail);

function onSuccess() {
    console.log('Camera stopped successfully.');
}

function onFail(message) {
    alert('Failed because: ' + message);
}

camera.cleanup()

Removes 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.

Supported Platforms

  • iOS

Kind: static method of camera Example

navigator.camera.cleanup(onSuccess, onFail);

function onSuccess() {
    console.log("Camera cleanup success.")
}

function onFail(message) {
    alert('Failed because: ' + message);
}

camera.onError : function

Callback function that provides an error message.

Kind: static typedef of camera

Param Type Description
message string The message is provided by the device's native code.

camera.onSuccess : function

Callback function that provides the image data.

Kind: static typedef of camera

Param Type Description
imageData string Data URI, or the image file URI, depending on cameraOptions in effect.

Example

// Show image captured with FILE_URI
function cameraCallback(imageData) {
    window.resolveLocalFileSystemURL(uri, (entry) => {
        let image = document.getElementById('myImage');
        image.src = entry.toURL();
    }, onError);
}

// Show image captured with DATA_URL
function cameraCallback(imageData) {
   var image = document.getElementById('myImage');
   image.src = imageData;
}

camera.CameraOptions : Object

Optional parameters to customize the camera settings.

Kind: static typedef of camera Properties

Name Type Default Description
quality number 50 Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.)
destinationType DestinationType FILE_URI Choose the format of the return value.
sourceType PictureSourceType CAMERA Set the source of the picture.
allowEdit Boolean false Deprecated. Allow simple editing of image before selection.
encodingType EncodingType JPEG Choose the returned image file's encoding.
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.
mediaType MediaType PICTURE Set the type of media to select from. Only works when PictureSourceType is PHOTOLIBRARY or SAVEDPHOTOALBUM.
correctOrientation Boolean Rotate the image to correct for the orientation of the device during capture.
saveToPhotoAlbum Boolean Save the image to the photo album on the device after capture.
See Android Quirks.
cameraDirection Direction BACK Choose the camera to use (front- or back-facing).

Camera

Camera.DestinationType : enum

Defines the output format of Camera.getPicture call.

Kind: static enum property of Camera Properties

Name Type Default Description
DATA_URL number 0 Return data uri. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI if possible
FILE_URI number 1 Return file uri (content://media/external/images/media/2 for Android)

Camera.EncodingType : enum

Kind: static enum property of Camera Properties

Name Type Default Description
JPEG number 0 Return JPEG encoded image
PNG number 1 Return PNG encoded image

Camera.MediaType : enum

Kind: static enum property of Camera Properties

Name Type Default Description
PICTURE number 0 Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
VIDEO number 1 Allow selection of video only, ONLY RETURNS URL
ALLMEDIA number 2 Allow selection from all media types

Camera.PictureSourceType : enum

Defines the output format of Camera.getPicture call.

Kind: static enum property of Camera Properties

Name Type Default Description
PHOTOLIBRARY number 0 Choose image from the device's photo library.
CAMERA number 1 Take picture from camera
SAVEDPHOTOALBUM number 2 Same as PHOTOLIBRARY, when running on Android or iOS 14+. On iOS older than 14, an image can only be chosen from the device's Camera Roll album with this setting.

Camera.Direction : enum

Kind: static enum property of Camera Properties

Name Type Default Description
BACK number 0 Use the back-facing camera
FRONT number 1 Use the front-facing camera

camera.getPicture Errata

Example

Take a photo and retrieve the image's file location:

// Don't forget to install cordova-plugin-file for resolveLocalFileSystemURL!

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.FILE_URI });

function onSuccess(imageURI) {
    window.resolveLocalFileSystemURL(uri, (entry) => {
        let img = document.getElementById('image');
        img.src = entry.toURL();
    }, onFail);
}

function onFail(message) {
    alert('Failed because: ' + message);
}

Take a photo and retrieve it as a Base64-encoded image:

/**
 * Warning: Using DATA_URL is not recommended! The DATA_URL destination
 * type is very memory intensive, even with a low quality setting. Using it
 * can result in out of memory errors and application crashes. Use FILE_URI
 * instead.
 */
navigator.camera.getPicture(onSuccess, onFail, { quality: 25,
    destinationType: Camera.DestinationType.DATA_URL
});

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}

Android Quirks

Android uses intents to launch the camera activity on the device to capture images, and on phones with low memory, the Cordova activity may be killed. In this scenario, the result from the plugin call will be delivered via the resume event. See the Android Lifecycle guide for more information. The pendingResult.result value will contain the value that would be passed to the callbacks (either the URI/URL or an error message). Check the pendingResult.pluginStatus to determine whether or not the call was successful.

Browser Quirks

Can only return photos as data URI image.

iOS Quirks

Including a JavaScript alert() in either of the callback functions can cause problems. Wrap the alert within a setTimeout() to allow the iOS image picker to fully close before the alert displays:

setTimeout(function() {
    // do your thing here!
}, 0);

CameraOptions Errata

Android Quirks

  • Any cameraDirection value results in a back-facing photo. (= You can only use the back camera)

  • allowEdit is unpredictable on Android and it should not be used! The Android implementation of this plugin tries to find and use an application on the user's device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution.

  • Camera.PictureSourceType.PHOTOLIBRARY and Camera.PictureSourceType.SAVEDPHOTOALBUM both display the same photo album.

  • Ignores the encodingType parameter if the image is unedited (i.e. quality is 100, correctOrientation is false, and no targetHeight or targetWidth are specified). The CAMERA source will always return the JPEG file given by the native camera and the PHOTOLIBRARY and SAVEDPHOTOALBUM sources will return the selected file in its existing encoding.

Sample: Take Pictures, Select Pictures from the Picture Library, and Get Thumbnails

The Camera plugin allows you to do things like open the device's Camera app and take a picture, or open the file picker and select one. The code snippets in this section demonstrate different tasks including:

Take a Picture

Before you can take a picture, you need to set some Camera plugin options to pass into the Camera plugin's getPicture function. Here is a common set of recommendations. In this example, you create the object that you will use for the Camera options, and set the sourceType dynamically to support both the Camera app and the file picker.

function setOptions(srcType) {
    var options = {
        // Some common settings are 20, 50, and 100
        quality: 50,
        destinationType: Camera.DestinationType.FILE_URI,
        // In this app, dynamically set the picture source, Camera or photo gallery
        sourceType: srcType,
        encodingType: Camera.EncodingType.JPEG,
        mediaType: Camera.MediaType.PICTURE,
        allowEdit: true,
        correctOrientation: true
    }
    return options;
}

Typically, you want to use a FILE_URI instead of a DATA_URL to avoid most memory issues. JPEG is the recommended encoding type for Android.

You take a picture by passing in the options object to getPicture, which takes a CameraOptions object as the third argument. When you call setOptions, pass Camera.PictureSourceType.CAMERA as the picture source.

function openCamera(selection) {

    var srcType = Camera.PictureSourceType.CAMERA;
    var options = setOptions(srcType);
    var func = createNewFileEntry;

    navigator.camera.getPicture(function cameraSuccess(imageUri) {

        displayImage(imageUri);
        // You may choose to copy the picture, save it somewhere, or upload.
        func(imageUri);

    }, function cameraError(error) {
        console.debug("Unable to obtain picture: " + error, "app");

    }, options);
}

Once you take the picture, you can display it or do something else. In this example, call the app's displayImage function from the preceding code.

function displayImage(imgUri) {

    var elem = document.getElementById('imageFile');
    elem.src = imgUri;
}

Take a Picture and Return Thumbnails (Resize the Picture)

To get smaller images, you can return a resized image by passing both targetHeight and targetWidth values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source).

function openCamera(selection) {

    var srcType = Camera.PictureSourceType.CAMERA;
    var options = setOptions(srcType);
    var func = createNewFileEntry;

    if (selection == "camera-thmb") {
        options.targetHeight = 100;
        options.targetWidth = 100;
    }

    navigator.camera.getPicture(function cameraSuccess(imageUri) {

        // Do something

    }, function cameraError(error) {
        console.debug("Unable to obtain picture: " + error, "app");

    }, options);
}

Select a File from the Picture Library

When selecting a file using the file picker, you also need to set the CameraOptions object. In this example, set the sourceType to Camera.PictureSourceType.PHOTOLIBRARY. To open the file picker, call getPicture just as you did in the previous example, passing in the success and error callbacks along with CameraOptions object.

function openFilePicker(selection) {

    var srcType = Camera.PictureSourceType.PHOTOLIBRARY;
    var options = setOptions(srcType);
    var func = createNewFileEntry;

    navigator.camera.getPicture(
        // success callback
        (imageUri) => {
            // Do something
        },
        // error callback
        (error) => {
            console.debug("Unable to obtain picture: " + error, "app");
        },
        options);
}

Select an Image and Return Thumbnails (resized images)

Resizing a file selected with the file picker works just like resizing using the Camera app; set the targetHeight and targetWidth options.

function openFilePicker(selection) {

    var srcType = Camera.PictureSourceType.PHOTOLIBRARY;
    var options = setOptions(srcType);
    var func = createNewFileEntry;

    if (selection == "picker-thmb") {
        // To downscale a selected image,
        // Camera.EncodingType (e.g., JPEG) must match the selected image type.
        options.targetHeight = 100;
        options.targetWidth = 100;
    }

    navigator.camera.getPicture(
        // success callback
        (imageUri) {
            // Do something with image
        },
        // error callback
        (error) => {
            console.debug("Unable to obtain picture: " + error, "app");
        },
        options);
}

Take a picture and get a FileEntry Object

If you want to do something like copy the image to another location, or upload it somewhere, an FileEntry is needed for the returned picture. To do this, call window.resolveLocalFileSystemURL on the file URI returned by the Camera app. If you need to use a FileEntry object, set the destinationType to Camera.DestinationType.FILE_URI in your CameraOptions object (this is also the default value).

NOTE: You need the File plugin to call window.resolveLocalFileSystemURL.

Here is the call to window.resolveLocalFileSystemURL. The image URI is passed to this function from the success callback of getPicture. The success handler of resolveLocalFileSystemURL receives the FileEntry object.

function getFileEntry(imgUri) {
    window.resolveLocalFileSystemURL(imgUri, function success(fileEntry) {

        // Example 1: Copy to app data directory
        window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function (dataDirectoryEntry) {
            fileEntry.copyTo(dataDirectoryEntry, "profilePic", onSuccess, onError);
        }, onError);

        // Example 2: Upload it!
        fileEntry.file(function (file) {
            var reader = new FileReader();

            reader.onloadend = function() {
                var xhr = new XMLHttpRequest();
                xhr.open('POST', 'https://myserver.com/upload');
                xhr.onload = function () {
                    // All done!
                };
                xhr.send(this.result);
            };

            reader.readAsArrayBuffer(file);
        }, onError);
    }, onError);
}

Installation

cordova plugin add cordova-plugin-camera

Usage

with the License. You may obtain a copy of the License at

API

For advanced use cases, this plugin may be appropriate.

This plugin defines a global navigator.camera object, which provides an API for taking pictures and choosing images from the device's image library.

Although the object is attached to the global navigator object, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    console.log(navigator.camera);
}

Dependencies

Metric Value
Files unknown
Lines of Code unknown
Dependencies unknown
Upstream license (harvested) Apache-2.0
Overlay license Anticommons 0.1.0

Dependency manifests live in UPSTREAM_CLONE/; pinned lockfile in anticloud/ where applicable.

Configuration

Plugin variables let you configure parts of a plugin and must be set during installation. To set these variables, append --variable {VARIABLE_NAME}={VALUE} to the cordova plugin add command for each variable. If you wish you change or remove any of the plugin variables, uninstall and reinstall with the updated variables.

  • ANDROIDX_CORE_VERSION

    Default: 1.6.+

    This variable allows you to configure the androidx.core:core dependency for this plugin only. Some plugins may include this dependency with hard-coded versions, so you can use this variable to try to match those versions and reduce conflicts.

    Example:

    cordova plugin add cordova-plugin-camera --variable ANDROIDX_CORE_VERSION=1.8.0
    

Contributing

Contributing to Apache Cordova

Anyone can contribute to Cordova. We welcome your contributions.

There are multiple ways to contribute:

  • Reporting bugs
  • Improving documentation
  • Contributing source code
  • And more...

For instructions on how to start, please take a look at our contribution overview page.

Details are explained there, but the important items are:

  • Check for GitHub issues that correspond to your contribution, and link or create them if necessary.
  • Run the tests so your patch doesn't break existing functionality.

Large contributions to the project require an Individual Contributor License Agreement (ICLA) to be signed and submitted to the Secretary of the Apache Software Foundation (ASF). Please read the ASF Contributor Agreements for more information.

Small contributions should be covered by clause 5 of the Apache-2.0 license.

We look forward to your contributions!

License

Upstream © its respective contributors under Apache-2.0 (harvested MIT/Apache-2.0/BSD source; see UPSTREAM_CLONE/LICENSE). This packaging overlay is licensed under Anticommons 0.1.0.

Upstream

Benchmarks

Measured by the Anticloud assurance suite. Every value below is read from this project's BENCH.json, produced by a real run — the SHA3-256 of that file is 3ceff1a359ead51757923ba3bcea43f971dcb77b2be2093645e81bd66527598a.

Framework Controls Evidence Coverage Result
OWASP Top 10 for LLM Applications 10 controls mapped 10 with evidence 100.0% PASS
OWASP Top 10 (2021) 9 controls mapped 9 with evidence 100.0% PASS
SOC 2 Type II readiness 9 controls mapped 9 with evidence 100.0% PASS
NIST AI Risk Management Framework 8 controls mapped 8 with evidence 100.0% PASS
NIST SP 800-53 Rev. 5 12 controls mapped 12 with evidence 100.0% PASS
NIST Cybersecurity Framework 2.0 8 controls mapped 8 with evidence 100.0% PASS
FedRAMP Rev. 5 10 controls mapped 10 with evidence 100.0% PASS
PCI DSS v4.0.1 11 controls mapped 11 with evidence 100.0% PASS
ISO/IEC 27001:2022 9 controls mapped 9 with evidence 100.0% PASS
MITRE ATT&CK v16 12 controls mapped 12 with evidence 100.0% PASS
ML Technology Readiness Level TRL 8 8/8 criteria PASS

Overall: 16/16 checks passing.

See ISOLATED_LAB_RESULTS/03_Result_Register.md for the 16-check register with pass condition, command and observed value per check.

Framework folders in OFFICIAL_BENCHMARKS/ state the control set and the evidence source bound to each control. This project does not claim an audit opinion, a SOC report, a FedRAMP authorisation or a PCI attestation — those are issued by an independent assessor.

Archives and Permanent Records

Platform Identifier Volume
Harvard Dataverse DOI 10.7910/DVN/YMJKOG 145 citable datasets
AIOSS verification kit DOI 10.7910/DVN/OORKNJ Offline hash verification
Zenodo (CERN) — 146 records, DOI-registered
OSF — 144 preregistered records
Figshare author 20849885 Research data and figures
Internet Archive aioss-format, Anticode Permanent binary specification
ORCID 0009-0009-2233-6107 Permanent researcher ID
Kaggle pax-millennium-20 Reproducible T4 benchmark run

Press and Independent Publication

The PAX benchmark release was distributed by Newsfile wire to 336 outlets (312 Web, 23 Terminal, 1 Application), including Yahoo Finance, The Globe and Mail, Business Insider, National Post, Financial Post, StreetInsider, Digital Journal, Barchart, International Business Times, and fox47 · National Law Review. Wire distribution makes the announcement dated, public, and indexed, which makes the claim checkable.

Downloads last month
52