Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
177529af
Commit
177529af
authored
Mar 31, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: resize photo if needed
Reduce the number of pixel managed by caman
parent
640a5e02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+35
-3
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
...em/web_page_module/scanner_gadget_document_scanner_js.xml
+2
-2
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
177529af
...
...
@@ -502,7 +502,31 @@
.
push
(
function
()
{
return
promiseCanvasToBlob
(
div
.
firstElementChild
);
});
}
function
resizePhoto
(
blob
,
original_width
,
original_height
)
{
var
expected_width
=
2000
;
if
(
original_width
<
expected_width
)
{
return
blob
;
}
// expected_height = parseInt((original_height * expected_width) / original_width);
// alert(expected_width + ' ' + expected_height);
return
new
RSVP
.
Queue
(
createImageBitmap
(
blob
,
{
resizeWidth
:
expected_width
,
// resizeHeight: expected_height,
resizeQuality
:
'
high
'
}))
.
push
(
function
(
bitmap
)
{
var
canvas
=
domsugar
(
'
canvas
'
);
canvas
.
width
=
bitmap
.
width
;
canvas
.
height
=
bitmap
.
height
;
canvas
.
getContext
(
'
2d
'
).
drawImage
(
bitmap
,
0
,
0
);
return
promiseCanvasToBlob
(
canvas
);
});
}
function
createLoadedImgElement
(
url
)
{
...
...
@@ -528,7 +552,9 @@
gadget
.
element
.
querySelector
(
'
video
'
).
srcObject
.
getVideoTracks
()[
0
]
),
original_blob_url
,
blob_url
;
blob_url
,
original_width
,
original_height
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
@@ -537,9 +563,12 @@
return
image_capture
.
getPhotoCapabilities
();
})
.
push
(
function
(
capabilities
)
{
original_width
=
capabilities
.
imageWidth
.
max
;
original_height
=
capabilities
.
imageHeight
.
max
;
return
image_capture
.
takePhoto
({
imageWidth
:
capabilities
.
imageWidth
.
max
,
imageHeight
:
capabilities
.
imageHeight
.
max
imageWidth
:
original_width
,
imageHeight
:
original_height
});
})
.
push
(
function
(
blob
)
{
...
...
@@ -551,6 +580,9 @@
div
=
gadget
.
element
.
querySelector
(
"
.camera-input
"
);
div
.
replaceChild
(
img
,
div
.
firstElementChild
);
return
resizePhoto
(
blob
,
original_width
,
original_height
);
})
.
push
(
function
(
blob
)
{
return
fixPhotoOrientation
(
blob
);
})
.
push
(
function
(
blob
)
{
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
177529af
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.58
248.12377.39526
</string>
</value>
<value>
<string>
982.58
327.23330.31351
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
158564
4055.38
</float>
<float>
158564
8785.07
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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