javascript - Resize video capture to canvas -


i've looked @ number of similar questions, , tried implementing solutions, i'm still having same problem, believe because have additional complication (and fact understanding of image manipulation limited).

here's situation: in web app have webcam picture capture (using getusermedia). <video> element displays feed, <canvas> sized 640 pixel width default. works fine on desktop browsers.

on devices screen width under 700px, site responsively resizes everything, including picture capture dialog, resizes 95% of screen width, <video> element display camera feed less 640px in width of time (those times matter here). video feed displays fine, can see entire camera field. every take picture, gets displayed on canvas (which resizes same video feed) clipped, depending on size of screen. say, canvas displays of original image, remains 640px wide, can.

i don't want resize actual image; i'd uploaded data @ end of day 640px image regardless of screen width. want user able see whole thing before s/he saves it.

i've tried playing width attribute (element attribute, not css) on canvas, did nothing, , changing width of video display shrink actual image, that's not want.

i played drawimage method should resizing, couldn't quite wanted. line thought should work, still gives me clipped image:

if($(window).width()<701){ var ratio = videoheight/videowidth;   var canvaswidth = $(window).width()*.86; // calculated width after css resizing   context.drawimage(video, 0, 0,width,height,0,0,canvaswidth,canvaswidth*ratio); } 

update

the following code show entire picture on canvas, shrinks it, , smaller image file, depending on screen width taken on:

context.drawimage(video, 0, 0,canvaswidth,canvaswidth*ratio); 

many thanks!


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -