0

I am creating a Blackberry10 app using the latest cordova frameworks.

I can successfully capture the an image using the framework however the image is not in the correct orientation.

Reading the documentation it seems blackberry do not support the 'correctOrientation' option.

Is the a way to support the correctly taken orientation or should i look at rotating the image myself? if so how would this be best achieved.

Thanks

Dan

   navigator.camera.getPicture(function onPhotoDataSuccess(imageData) {
    console.log(imageData);
     success(imageData);
},function onFail(message) {
    alert('Failed because: ' + message);
}
,
{
    quality : 100,
    destinationType : Camera.DestinationType.DATA_URL,
    sourceType : Camera.PictureSourceType.CAMERA,
    allowEdit : true,
    encodingType: Camera.EncodingType.JPEG,
    targetWidth: 100,
    targetHeight: 100,
    saveToPhotoAlbum: false 
});
Dan
  • 1,447
  • 2
  • 14
  • 30

1 Answers1

0

Most probably you'll have to do it yourself.

I've never done it myself, but apparently it is possible to rotate an image in JavaScript using a canvas hack, as shown here:

Javascript function to Rotate a base 64 image by X degrees and return new base64

HTML Canvas image to Base64 problem

Canvas is only partially supported in Android 2.3 and older, but for BB10 you should be fine.

I'd rather code a custom Cordova plugin to do it from native code. You'd then take the picture as usual, and only in BB you'd also pass the resulting image data to a plugin that rotates the image and returns the corrected image back to the JavaScript callback.

As a final note, if you needed to reuse your code in the future for larger image sizes, consider using FILE_URI as destination type, because images can be very large, and the encoded image would be even larger. Now for your example, a 100x100 image shouldn't pose a memory problem, but to pass data back and forth from the plugin to the JS code I think it is better to pass file URIs instead of encoded strings.

Community
  • 1
  • 1
Mister Smith
  • 27,417
  • 21
  • 110
  • 193