Commit 5558c086 authored by dtati's avatar dtati

rezise_image

parent dff3648f
......@@ -3,6 +3,7 @@ import axios from 'axios';
import helper from '../config/helperConfig';
import * as skyid from 'skyid-sdk-web';
const SkyIdentification = () => {
const [selectedFile, setSelectedFile] = useState(null);
const [responseLogin, setResponseLogin] = useState(null);
......@@ -18,8 +19,7 @@ const SkyIdentification = () => {
const readImage = (file) => {
const reader = new FileReader();
reader.readAsDataURL(file);
setSelectedFile(file);
resizeImage(file);
reader.onload = function () {
setImageSrc(reader.result);
};
......@@ -155,7 +155,46 @@ const SkyIdentification = () => {
let skyid_liveness = document.getElementById('skyid_liveness');
skyid_liveness.innerHTML = skyid.skyid_component;
skyid.skyid_fa_setup_sdk();
}
};
// rezise image function
const resizeImage = (file) => {
const reader = new FileReader();
reader.onload = (e) => {
const img = new Image();
img.src = e.target.result;
img.onload = () => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 1000;
canvas.height = 600;
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
canvas.toBlob(
(blob) => {
if (blob) {
const resizedFile = new File([blob], file.name, {
type: file.type,
lastModified: Date.now(),
});
console.log('Resized File:', resizedFile);
setSelectedFile(resizedFile);
} else {
console.error('Failed to create Blob.');
}
},
file.type, // Set the image type explicitly
0.9 // Adjust the quality (0.0 to 1.0, 1.0 for maximum quality)
);
};
};
reader.readAsDataURL(file);
};
const setMessage = () => {
skyid.message_variables.skyid_fa_sdk_access_error_message = "Votre token n'est pas valide";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment