Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. let options: CameraOptions = {
  2. quality: 30,
  3. targetHeight: 500,
  4. targetWidth: 500,
  5. destinationType: this.camera.DestinationType.DATA_URL,
  6. encodingType: this.camera.EncodingType.JPEG,
  7. mediaType: this.camera.MediaType.PICTURE,
  8. correctOrientation: true
  9. };
  10. var me = this;
  11. return this.camera.getPicture(options).then(function(data) {
  12. return new Promise((resolve, reject) => {
  13. me.getDimensions("data:image/jpeg;base64," + data, function(results) {
  14. console.log(`Results for getDimenstions: width - ${results.width}, height - ${results.height}`);
  15. var img = new ReportImage();
  16. img.data = "data:image/jpeg;base64," + data;
  17. img.width = results.width;
  18. img.height = results.height;
  19. resolve(img);
  20. });
  21. });
  22.  
  23. getDimensions(data, cb) {
  24. var i = new Image();
  25.  
  26. i.onload = function(){
  27. return cb({width: i.naturalWidth, height: i.naturalHeight});
  28. };
  29.  
  30. i.src = data;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement