Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
reactjs-skyIdentification
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-skyIdentification
Commits
5558c086
Commit
5558c086
authored
Dec 28, 2023
by
dtati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rezise_image
parent
dff3648f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
3 deletions
+42
-3
src/Components/SkyIdentification.js
src/Components/SkyIdentification.js
+42
-3
No files found.
src/Components/SkyIdentification.js
View file @
5558c086
...
...
@@ -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
"
;
...
...
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