
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@spoonconsulting/cordova-plugin-simple-camera-preview
Advanced tools
Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.
Cordova plugin that allows simple camera preview and taking pictures from Javascript and HTML
cordova plugin add https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview.git
ionic cordova plugin add https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview.git
Make the webview html background color transparent.
html, body, .ion-app, .ion-content {
background-color: transparent;
}
for newer version ionic use the following:
html, body, .ion-app, .ion-content {
--background: transparent;
}
Make sure to set up the camera size as follows:
const aspectRatio = 3/4; // or 9/16
const cameraSize = this.getCameraSize(aspectRatio);
getCameraSize(aspectRatio) {
let height;
let width;
const ratio = 4 / 3;
const min = Math.min(window.innerWidth, window.innerHeight);
[width, height] = [min, Math.round(min / aspectRatio)];
if (this.isLandscape()) {
[width, height] = [height, width];
}
return {
x: (window.innerWidth - width) / 2,
y: (window.innerHeight - height) / 2,
width,
height,
};
}
isLandscape() {
return Math.abs(window.orientation % 180) === 90;
}
Uses Google's CameraX API
Starts the camera preview instance.
const params = {
targetSize: 1024,
lens: 'auto', // Camera lens (auto or wide). Default is auto.
direction: 'back', // Camera direction (front or back). Default is back.
aspectRatio: '3:4', // Camera aspect ratoio (3:4 or 9:16). Default is 3:4.
...cameraSize,
}
SimpleCameraPreview.enable(params, () => {
console.log("Camera enabled");
});
Stops the camera preview instance.
SimpleCameraPreview.disable(params, () => {
console.log("Camera disabled");
});
Take the picture
let options = {
flash: true,
};
SimpleCameraPreview.capture(options, (imagaeNativePath) => {
console.log(imagaeNativePath);
});
Set the camera frame size
let size = {
x: 0,
y: 0,
width: 1080,
height: 1920,
};
SimpleCameraPreview.setSize(size, () => {
console.log("Camera frame size set");
});
Check if device has ultra-wide camera
SimpleCameraPreview.deviceHasUltraWideCamera(size, (value: boolean) => {
console.log("Device has ultra-wide camera?: ", value);
});
Switch camera between wide or auto and set the camera direction (front or back) dynamically. Change camera aspect ratio.
The options variable can take the following keys:
lens:
"wide"
– Use a wide-angle lens."auto"
– Automatically select the best available lens.direction:
"front"
– Use the front-facing camera."back"
– Use the rear-facing camera.aspectRatio:
"3:4"
– Display 3/4 preview."9:16"
– Display 9/16 preview.Currently, the wide-angle lens functionality is not supported for the front-facing camera. If the lens
is set to "wide"
and the direction
is set to "front"
, the camera will default to the "auto"
lens instead of switching to the wide lens.
const params = {
lens: "wide",
direction: "back", // Specify camera direction
aspectRatio: "9:16",
...cameraSize,
};
SimpleCameraPreview.switchCameraTo(
params,
(value: unknown) => {
return (typeof value === "boolean" ? value : false);
},
(e: unknown) => {
console.log("cannot switch camera: ", e);
}
);
2.0.44 (2025-07-15)
FAQs
Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.
The npm package @spoonconsulting/cordova-plugin-simple-camera-preview receives a total of 158 weekly downloads. As such, @spoonconsulting/cordova-plugin-simple-camera-preview popularity was classified as not popular.
We found that @spoonconsulting/cordova-plugin-simple-camera-preview demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.