0

I have been using the following code to grab a photo and display it in html works great.

 function takePicture() {

    navigator.camera.getPicture(
        function(uri) {
            var img = document.getElementById('camera_image1');
            img.style.visibility = "visible";
            img.style.display = "block";
            img.src = uri;
            document.getElementById('camera_status').innerHTML = "Success";

        },

        { quality: 50, allowEdit: true, destinationType: navigator.camera.DestinationType.FILE_URI});
};

html later

 <img style="width:144px;height:144px;" id="camera_image1" src="nophoto.jpg"/>

but... this does not save the image to the cameras photo library so I tweaked line to

  navigator.device.capture.captureImage

This now captures image to library but

  1. no longer displays in html
  2. No longer allows me to edit the photo after I have taken photo in the camera 'app'

Any pointer much appreciated.

PhoneGap 1.3

adamprocter
  • 856
  • 1
  • 15
  • 31

1 Answers1

1

When captureImage succeeds, it passes an array of MediaFile objects to your callback (an array since it's possible to have more than one result, but your example will only have one). The MediaFile objects contain the full path. You should be able to use code similar to what you have above to point to the file uri.

As to your second question - not sure what you expect here. "Image Capture" isn't editing per se. You would need to build your own editor using JavaScript - which would be overkill probably.

Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
  • Thanks I looked at the MediaFile objects thing and go a little confused. Ill look harder. – adamprocter Jan 23 '12 at 23:10
  • As for editing I mean when I used the camera.getPicture and set allowedit:true I could tweak photo before I 'saved' it. Basic cropping really and I wanted to keep that feature. thanks again – adamprocter Jan 23 '12 at 23:11
  • The Camera API provides more functionality than the Capture API, that is why you can't do an edit before saving with Capture. – Simon MacDonald Jan 24 '12 at 00:51
  • Ah so then can I please reverse my question how can I use camera API as above but also save to device library ? – adamprocter Jan 24 '12 at 18:47