Commit 3dfbb547 authored by dtati's avatar dtati

rezise_image-1

parent 5558c086
......@@ -19,6 +19,7 @@ const SkyIdentification = () => {
const readImage = (file) => {
const reader = new FileReader();
//setSelectedFile(file);
resizeImage(file);
reader.onload = function () {
setImageSrc(reader.result);
......@@ -71,9 +72,9 @@ const SkyIdentification = () => {
formData.append('institution_id', helper.institution_id);
formData.append('application_id', helper.skyid_fa_sdk_appId);
formData.append('channel_id', "02");
formData.append('service_id', "01");
formData.append('service_id', "09");
formData.append('sub_service_id', "005");
formData.append("request_data", '{"doc_type":"01"}');
formData.append("request_data", '{"doc_type":"09"}');
axios.post(helper.OCR_url, formData, {
headers: {
Authorization: `Bearer ${bearToken}`,
......@@ -159,20 +160,27 @@ const SkyIdentification = () => {
// 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;
if(img.width < img.height){
console.log("rezised")
canvas.width = 600;
canvas.height = 1000;
}
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
if(img.width > canvas.width || img.height > canvas.height){
console.log("Im here")
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
canvas.toBlob(
(blob) => {
if (blob) {
......@@ -189,6 +197,7 @@ const SkyIdentification = () => {
file.type, // Set the image type explicitly
0.9 // Adjust the quality (0.0 to 1.0, 1.0 for maximum quality)
);
}
};
};
......
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