From 07d617da919f71af26638d769bc2bf6118b8ecff Mon Sep 17 00:00:00 2001 From: Sli Date: Wed, 21 Aug 2024 15:47:53 +0200 Subject: [PATCH] Get video resolution from the camera settings for a better image quality --- core/templates/core/user_edit.jinja | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/core/templates/core/user_edit.jinja b/core/templates/core/user_edit.jinja index c7b3369e..ea4886bd 100644 --- a/core/templates/core/user_edit.jinja +++ b/core/templates/core/user_edit.jinja @@ -68,10 +68,6 @@ Alpine.data("camera_{{ field_name }}", () => ({ can_edit_picture: false, - /* Those values are based on the unknwon.jpg file */ - width: 417, - height: 434, - loading: false, is_camera_enabled: false, is_camera_error: false, @@ -110,8 +106,6 @@ this.loading = false; this.is_camera_enabled = true; this.video.srcObject = stream; - this.video.width = 320; - this.video.height = 240; this.video.play(); }) .catch((err) => { @@ -125,8 +119,9 @@ const context = canvas.getContext("2d"); /* Create the image */ - canvas.width = this.video.width; - canvas.height = this.video.height; + let settings = this.video.srcObject.getTracks()[0].getSettings(); + canvas.width = settings.width; + canvas.height = settings.height; context.drawImage(this.video, 0, 0, canvas.width, canvas.height); this.picture = canvas.toDataURL("image/png");