Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
991 views
in Technique[技术] by (71.8m points)

base64 - Javascript - Dimensions of blob returned by the promise of imageCapture.takePhoto function

In the following code, I have set the max image width to 640. I am converting the blob to base64 string and then sending it to the server. On the server I am getting the image of the original width i.e. 1280. It looks like the constraints are not applied on the captured image. How do I force the returned image blob to have size of 640?

function takepicture(mediaStream) {

imageCapture = new ImageCapture(mediaStream.getVideoTracks()[0]);   
imgCapture = imageCapture.takePhoto({ imageWidth : 640}).then(function(blob) {
     reader = new FileReader();
     reader.readAsDataURL(blob); 
     reader.onloadend = function() {
        base64data = reader.result.split(',')[1];
        // base64data is uploaded to server
    }        
  }).catch(function(error) {
    console.log('error: ', error);
  });     

}

question from:https://stackoverflow.com/questions/66049005/javascript-dimensions-of-blob-returned-by-the-promise-of-imagecapture-takephot

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...