Camera: Wrong orientation with Windows 10 while capturing


#1

While i am capturing an image from my camera in windows 10 IONIC app, the image captured in portrait mode is displayed as Landscape one…help me out from this bug please…I am using cordova-plugin-camera.


#2

I am having the same problem. Did you find a solution?

Cheers


#3

Ya found a solution, where i am converting the image again to 90 degrees by using canvas. Hope this may help you.

$cordovaCamera.getPicture(options).then(function(imageData) {
var attachment = {};
var random = Math.random().toString(36).substring(8);
var randomName = random + “.jpg”;
var img = new Image();
img.crossOrigin = ‘Anonymous’;
img.onload = function() {
var canvas = document.createElement(‘CANVAS’),
ctx = canvas.getContext(‘2d’),
dataURL,
ch,
cw,
cx = 0,
cy = 0;
canvas.height = this.height;
canvas.width = this.width;
ctx.drawImage(this, 0, 0);

 cw = this.height;
 ch = this.width;
 cy = this.height * (-1);

 // rotate 90 degrees
 canvas.setAttribute('width', cw);
 canvas.setAttribute('height', ch);
 ctx.rotate(90 * Math.PI / 180);
 ctx.drawImage(this, cx, cy);

 dataURL = canvas.toDataURL("image/jpeg");
 dataURL = dataURL.replace('data:image/jpeg;base64,', '');
 attachment = {
  "FileId" : "",
  "FileName" : randomName,
  "FileData" : dataURL,
  "CreatedBy" : "",
  "UpdatedBy" : "",
  "newImage" : true,
  "FileContentType":"image/jpeg"
 };
 $scope.attachmentsArray.push(attachment);
 $scope.isAttachmentsVisible = true;
 canvas = null;
 $scope.$apply();
};
img.src = imageData;    

});


#5

Thanks Naren, this solved my problem.


#6

U r welcome daveed…