Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
reactjs-skyFaceAnalysis
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ProjetDemo
reactjs-skyFaceAnalysis
Commits
790060a1
Commit
790060a1
authored
Jan 02, 2024
by
dtati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resize image
parent
8550f32c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
6 deletions
+52
-6
src/Components/SkyIdentification.js
src/Components/SkyIdentification.js
+7
-6
src/config/helperConfig.js
src/config/helperConfig.js
+45
-0
No files found.
src/Components/SkyIdentification.js
View file @
790060a1
...
@@ -15,10 +15,11 @@ const SkyIdentification = () => {
...
@@ -15,10 +15,11 @@ const SkyIdentification = () => {
readImage
(
event
.
target
.
files
[
0
]);
readImage
(
event
.
target
.
files
[
0
]);
};
};
const
readImage
=
(
file
)
=>
{
const
readImage
=
async
(
file
)
=>
{
const
reader
=
new
FileReader
();
const
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
reader
.
readAsDataURL
(
file
);
setSelectedFile
(
file
);
const
resizedImage
=
await
helper
.
resizeImage
(
file
);
setSelectedFile
(
resizedImage
);
reader
.
onload
=
function
()
{
reader
.
onload
=
function
()
{
setImageSrc
(
reader
.
result
);
setImageSrc
(
reader
.
result
);
};
};
...
@@ -78,14 +79,14 @@ const SkyIdentification = () => {
...
@@ -78,14 +79,14 @@ const SkyIdentification = () => {
}
}
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
console
.
log
(
'
ocr
success
'
,
response
.
data
);
console
.
log
(
'
success
'
,
response
.
data
);
if
(
response
.
data
.
status_code
===
"
000
"
)
{
if
(
response
.
data
.
status_code
===
"
000
"
)
{
setResponseLiveness
(
response
.
data
);
setResponseLiveness
(
response
.
data
);
skyid
.
skyid_fa_start_face_scan
(
skyid_face_scan_end_callbackfacematching
,
processFaTimeOut
);
skyid
.
skyid_fa_start_face_scan
(
skyid_face_scan_end_callbackfacematching
,
processFaTimeOut
);
}
}
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
error
(
'
ocr
error
'
,
error
);
console
.
error
(
'
error
'
,
error
);
window
.
location
.
reload
()
window
.
location
.
reload
()
});
});
};
};
...
@@ -106,14 +107,14 @@ const SkyIdentification = () => {
...
@@ -106,14 +107,14 @@ const SkyIdentification = () => {
}
}
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
console
.
log
(
'
ocr
success
'
,
response
.
data
);
console
.
log
(
'
success
'
,
response
.
data
);
if
(
response
.
data
.
status_code
===
"
000
"
)
{
if
(
response
.
data
.
status_code
===
"
000
"
)
{
setResponseFaceMatching
(
response
.
data
);
setResponseFaceMatching
(
response
.
data
);
skyid
.
skyid_fa_stop_webcam
();
skyid
.
skyid_fa_stop_webcam
();
}
}
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
error
(
'
ocr
error
'
,
error
);
console
.
error
(
'
error
'
,
error
);
skyid
.
skyid_fa_stop_webcam
();
skyid
.
skyid_fa_stop_webcam
();
window
.
location
.
reload
()
window
.
location
.
reload
()
});
});
...
...
src/config/helperConfig.js
View file @
790060a1
...
@@ -29,6 +29,51 @@ export default {
...
@@ -29,6 +29,51 @@ export default {
bytes
[
i
]
=
binary_string
.
charCodeAt
(
i
);
bytes
[
i
]
=
binary_string
.
charCodeAt
(
i
);
}
}
return
bytes
.
buffer
;
return
bytes
.
buffer
;
},
resizeImage
(
file
)
{
console
.
log
(
file
);
const
defaultQualityRatio
=
0.9
;
const
imageType
=
file
.
type
||
'
image/jpeg
'
;
return
new
Promise
((
resolve
,
reject
)
=>
{
const
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
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
)
{
canvas
.
width
=
600
;
canvas
.
height
=
1000
;
}
if
(
img
.
width
>
canvas
.
width
||
img
.
height
>
canvas
.
height
)
{
ctx
.
drawImage
(
img
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
ctx
.
canvas
.
toBlob
(
(
blob
)
=>
{
resolve
(
new
File
([
blob
],
file
.
name
,
{
type
:
imageType
,
lastModified
:
Date
.
now
(),
})
);
},
imageType
,
defaultQualityRatio
);
}
};
};
reader
.
onerror
=
(
error
)
=>
{
reject
(
error
);};
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment