title: Cordova how to rotate a picture from camera
body: <p>i take a picture with cordova camera plugin
  camera.getPicture() api</p>
  
  <p>and get a base64 image how i rotate 90 right this base64 image and get new base64 string to save 
  my code:</p>
  
  <pre><code>Camera.getPicture(options).then(function(imageURI) {
          var img = new Image();
          img.src = "data:image/png;base64," + imageURI;
  
          var rotate = false;
  
          if (img.width &gt; img.height) {
              rotate = true;
          }
  
           uploadImage(imageURI, activeIndex, rotate);
  
      }, function(err) {
          console.log(err);
          $ionicLoading.hide();
      });
  </code></pre>
  
  <p>function to rotate the picture</p>
  
  <pre><code> var rotateImage = function (base64ImageSrc) {
      var canvas = document.createElement('canvas');
      var img = new Image();
      img.src = base64ImageSrc;
      var context = canvas.getContext('2d');
  
      // translate context to center of canvas
      context.translate(canvas.width / 2, canvas.height / 2);
  
      // rotate 45 degrees clockwise
      context.rotate(Math.PI / 4);
  
      console.log(canvas.toDataURL());
      var ImageUrl = canvas.toDataURL();
      ImageUrl = ImageUrl.split("data:image/png;base64,");
      ImageUrl = ImageUrl[1];
      console.log(ImageUrl);
      return ImageUrl;
  };
  </code></pre>