Take square image with Cordova (Phonegap) Camera API?

Take square image with Cordova (Phonegap) Camera API?

Content Index :

Take square image with Cordova (Phonegap) Camera API?
Tag : ios , By : CHeMoTaCTiC
Date : November 24 2020, 05:47 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Phonegap/Cordova not showing camera

Tag : development , By : Steven Weber
Date : March 29 2020, 07:55 AM
I hope this helps you . YES! i finally got it to work, i downgraded from phonegap 2.3.0 to 2.0.0
For anyone with the same problem here is my final code:
    <script src="assets/js/cordova-2.0.0.js"></script>
    <script type="text/javascript" charset="utf-8">

        // Called when capture operation is finished
        function captureSuccess(mediaFiles) {
            //var i, len;
            //for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            //    //uploadFile(mediaFiles[i]);
            //navigator.notification.alert('Weee', null, 'Great success!');

        // Called if something bad happens.
        function captureError(error) {
            //var msg = 'An error occurred during capture: ' + error.code;
            //navigator.notification.alert(msg, null, 'Uh oh!');

        // A button will call this function
        function captureImage() {
            // Launch device camera application, 
            // allowing user to capture up to 2 images
            navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });

        // Upload files to server
        function uploadFile(mediaFile) {
            var ft = new FileTransfer(),
                path = mediaFile.fullPath,
                name = mediaFile.name;

                function (result) {
                    console.log('Upload success: ' + result.responseCode);
                    console.log(result.bytesSent + ' bytes sent');
                function (error) {
                    console.log('Error uploading file ' + path + ': ' + error.code);
                { fileName: name });

    <script type="text/javascript" charset="utf-8">

        var pictureSource;   // picture source
        var destinationType; // sets the format of returned value 

        // Wait for Cordova to connect with the device
        function onLoad() { document.addEventListener("deviceready", onDeviceReady, false); }

        // Cordova is ready to be used!
        function onDeviceReady() {
            pictureSource = navigator.camera.PictureSourceType;
            destinationType = navigator.camera.DestinationType;
            alert("device is ready");

        // Called when a photo is successfully retrieved
        function onPhotoDataSuccess(imageData) {
            // Uncomment to view the base64 encoded image data
            // console.log(imageData);

            // Get image handle
            var smallImage = document.getElementById('smallImage');

            // Unhide image elements
            smallImage.style.display = 'block';

            // Show the captured photo
            // The inline CSS rules are used to resize the image
            smallImage.src = "data:image/jpeg;base64," + imageData;

        // Called when a photo is successfully retrieved
        function onPhotoURISuccess(imageURI) {
            // Uncomment to view the image file URI 
            // console.log(imageURI);

            // Get image handle
            var largeImage = document.getElementById('largeImage');

            // Unhide image elements
            largeImage.style.display = 'block';

            // Show the captured photo
            // The inline CSS rules are used to resize the image
            largeImage.src = imageURI;

        // A button will call this function
        function capturePhoto() {
            // Take picture using device camera and retrieve image as base64-encoded string
            navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
                quality: 50,
                destinationType: destinationType.DATA_URL

        // A button will call this function
        function capturePhotoEdit() {
            // Take picture using device camera, allow edit, and retrieve image as base64-encoded string  
            navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
                quality: 20, allowEdit: true,
                destinationType: destinationType.DATA_URL

        // A button will call this function
        function getPhoto(source) {
            // Retrieve image file location from specified source
            navigator.camera.getPicture(onPhotoURISuccess, onFail, {
                quality: 50,
                destinationType: destinationType.FILE_URI,
                sourceType: source

        // Called if something bad happens.
        function onFail(message) {
            alert('Failed because: ' + message);

<body onLoad="onLoad()">
    <button onclick="capturePhoto();">Capture Photo</button> <br><br>
    <button onclick="capturePhotoEdit();">Capture Editable Photo</button> <br><br>
    <button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br><br>
    <button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button><br><br>
    <img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
    <img style="display:none;" id="largeImage" src="" />
    <br><button onclick="captureImage();">Capture Image</button> <br>
    <?xml version="1.0" encoding="UTF-8"?>
<widget xmlns       = "http://www.w3.org/ns/widgets"
xmlns:gap   = "http://phonegap.com/ns/1.0"
id      = "com.phonegap.getting.started"
version     = "1.0.0">



<author href="http://bla.github.com"

<icon src="icon.png" gap:role="default" />

<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/network"/>
  <feature name="http://api.phonegap.com/1.0/file"/>
  <feature name="http://api.phonegap.com/1.0/camera"/>
  <feature name="http://api.phonegap.com/1.0/media"/>
  <feature name="http://api.phonegap.com/1.0/device"/>

  <feature name="http://api.phonegap.com/1.0/notification"/>
  <feature name="http://api.phonegap.com/1.0/battery"/>

<preference name="orientation" value="portrait" />
<preference name="webviewbounce" value="false" />
<preference name="prerendered-icon" value="true" />
  <preference name="phonegap-version" value="2.0.0" />

  <preference name="fullscreen" value="false" />
  <preference name="stay-in-webview" value="false" />
  <preference name="ios-statusbarstyle" value="default" />
  <preference name="android-minSdkVersion" value="7" />
  <preference name="android-installLocation" value="internalOnly" />
  <preference name="target-device" value="universal" />
  <preference name="autohide-splashscreen" value="true" />
  <preference name="load-url-timeout" value="60000" />
  <preference name="show-splashscreen-spinner" value="true" />
  <preference name="show-splash-screen-spinner" value="true" />
  <preference name="allow-inline-media-playback" value="false" />
  <preference name="launch-mode" value="standard" />

  <plugin name="Capture" value="CDVCapture" />
  <plugin name="Camera" value="CDVCamera" />

error retrieving image is failure callback camera plugin - Phonegap/Cordova

Tag : cordova , By : Frank Bradley
Date : March 29 2020, 07:55 AM
this one helps. Debugging the plugin source code I noticed an exception cause by a C# class present in cordovalib.
I solved by upgrading from 3.6 to cordova 3.7.

Uploading camera image to server using phonegap/cordova and access the data returned by server

Tag : php , By : Xander
Date : March 29 2020, 07:55 AM
it fixes the issue I figured out the answer myself.Just want to share with you all.I used alert(JSON.stringify(r)).Now I know the format of the returned json object .Knowing that I have easily printed out the image name.r.response helped me retrieve the generated image name.

Cordova/Phonegap: Is the camera enabled?

Tag : cordova , By : Brandon
Date : March 29 2020, 07:55 AM
around this issue Assuming by "figure out if the camera is enabled or disabled for my application" you mean "is the camera authorized for use by my application" (as it's not possible to "disable" the camera on Android or iOS), you can use cordova-diagnostic-plugin to do this:
First install it:
$ cordova plugin add cordova.plugins.diagnostic
        // Display some message to user
}, function(error){
    console.error("The following error occurred: "+error);

phonegap cant install cordova camera

Tag : xcode , By : Pieter Taelman
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How can I achieve automatic scrolling in my text view when text comes down to the keyboard level in Swift?
  • how to get the location with the CLLocationManager every 10 secondes?
  • Calling completion handler of a function from Timer selector function Swift
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • Why does the UIBarButtonItem not show up when I create it with code?
  • How to prevent following view controller inheriting navigation view controller bar?
  • What does it mean when .xcodeproj files are shown in red in Xcode?
  • Xcode SwiftUI how to scroll the Preview Canvas?
  • Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table c
  • xcodebuild failed with return code: 65 - using CLI/Appcenter but no error messages
  • "'isDeveloperModeEnabled' is deprecated: This no longer needs to be set during development. " What is isDevelo
  • Right click in UIKit for Mac
  • How we Support Dark Mode in Current iOS App with iOS 13?
  • Security vulnerablility issue in ios mobile app
  • How to set a background color for the viewController in swiftUI?
  • SwiftUI : Segue navigation
  • iOS 13 Custom UISearchBar _searchField crash
  • USDZ models have holes in SceneKit but not QuickLook
  • Why does iOS Password Autofill not prompt to save password on keychain?
  • Pushing information to firebase after event is created(Firebase-Realtime-Database)
  • Xcode 11 Beta and Carthage bootstrap
  • How to change the status bar background color and text color on iOS 13?
  • Using Core Data with SwiftUI
  • How should I do to wait all the data downloaded completely and show on TableView?
  • Can we specify the number of rows that can be shown in each section of a collection view
  • Why sometimes completion handler not called?
  • Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements
  • In UIKit we can set label.numberOfLines = 0 when we do not know how many lines the text will take? What is the alternati
  • Swift ISO8601 format to Date returning fatal error
  • SwiftUI Login Page Layout
  • Xcode: Could not locate installed application. Install claimed to have succeeded, but application could not be found on
  • See the TestFlight crash log in the Xcode
  • Why does zero UIView's CALayer.speed stops UIAlertController's buttons from working?
  • Firestore collectionGroup query returns empty result
  • Modify text in SwiftUI
  • CNCopyCurrentNetworkInfo with iOS 13
  • WWDC 2019 - iOS13 April 2020 requirement
  • Nativescript IPhone X - How to "hide" home indicator behind two swipes to go to home screen
  • Should I use a singleton location manager in Swift?
  • Accessibility problem in reusable TableViewCell
  • Remove top line containing Done button from Keyboard Using Storyboard or in Swift
  • Swift Storyboard - Centring an Icon and multi-line text horizontally
  • viewDidAppear is delayed by 0.5 sec
  • Pass URL values to SecondView Controller WebView (WKWebView)
  • How to upload images faster on iOS, when using takePictureAsync?
  • Tableview multiple sections with one floating header
  • UITextView: Huge Memory Usage
  • How to put a logo in NavigationView in swiftui?
  • How can I load an UIImage into a SwiftUI Image asynchronously?
  • How to remove highlight on tap of List with SwiftUI?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com