Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
V
vuejs-skyFaceAnalyst
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
vuejs-skyFaceAnalyst
Commits
49df378a
Commit
49df378a
authored
Jan 02, 2024
by
dtati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rezise image
parent
95833b6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
src/components/HelloWorld.vue
src/components/HelloWorld.vue
+2
-2
src/config/helperConfig.js
src/config/helperConfig.js
+45
-0
No files found.
src/components/HelloWorld.vue
View file @
49df378a
...
...
@@ -23,13 +23,13 @@ export default {
this
.
readImage
(
selectedFile
);
}
},
readImage
(
file
)
{
async
readImage
(
file
)
{
const
reader
=
new
FileReader
();
reader
.
onload
=
(
e
)
=>
{
this
.
imagePreview
=
e
.
target
.
result
;
};
reader
.
readAsDataURL
(
file
);
this
.
binaryFile
=
file
;
this
.
binaryFile
=
await
Helper
.
resizeImage
(
file
)
this
.
init
()
},
startScanFace
(){
...
...
src/config/helperConfig.js
View file @
49df378a
...
...
@@ -29,6 +29,51 @@ export default {
bytes
[
i
]
=
binary_string
.
charCodeAt
(
i
);
}
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
);};
});
}
}
\ No newline at end of file
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