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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Gambier
erp5
Commits
28b9d317
Commit
28b9d317
authored
Apr 01, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: add glfx support
Use the GPU to speed up the image manipulation process.
parent
9e8adf0f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
27 deletions
+173
-27
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.html
...web_page_module/scanner_gadget_document_scanner_html.html
+1
-0
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.xml
.../web_page_module/scanner_gadget_document_scanner_html.xml
+2
-2
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+75
-23
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
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/WebSection_getDocumentScannerPrecacheManifestList.py
...nner/WebSection_getDocumentScannerPrecacheManifestList.py
+2
-0
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/glfx.js.js
...emplateItem/portal_skins/erp5_document_scanner/glfx.js.js
+59
-0
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/glfx.js.xml
...mplateItem/portal_skins/erp5_document_scanner/glfx.js.xml
+32
-0
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.html
View file @
28b9d317
...
...
@@ -19,6 +19,7 @@
<script
type=
"text/javascript"
src=
"cropper.min.js"
></script>
<script
type=
"text/javascript"
src=
"domsugar.js"
></script>
<script
type=
"text/javascript"
src=
"caman.full.min.js"
></script>
<script
type=
"text/javascript"
src=
"glfx.js"
></script>
<script
type=
"text/javascript"
src=
"gadget_document_scanner.js"
></script>
<title>
Gadget Document Scanner
</title>
</head>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.xml
View file @
28b9d317
...
...
@@ -242,7 +242,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.
7390.34742.27767
</string>
</value>
<value>
<string>
982.
46775.50354.51694
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
158
2765422.37
</float>
<float>
158
5665387.68
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
28b9d317
/*jslint indent: 2, unparam: true, bitwise: true */
/*global rJS, RSVP, window, document, navigator, Cropper, Promise, JSON, jIO,
promiseEventListener, domsugar, createImageBitmap, FormData, Caman,
FileReader, DataView, URL*/
FileReader, DataView, URL
, fx
*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
caman
,
FileReader
,
DataView
,
URL
)
{
FileReader
,
DataView
,
URL
,
fx
)
{
"
use strict
"
;
//////////////////////////////////////////////////
...
...
@@ -109,6 +109,29 @@
return
new
RSVP
.
Promise
(
waitForStream
,
canceller
);
}
function
handleGfx
(
canvas
,
settings
)
{
var
webgl_canvas
=
fx
.
canvas
(),
texture
=
webgl_canvas
.
texture
(
canvas
),
tmp
;
// apply the ink filter
tmp
=
webgl_canvas
.
draw
(
texture
);
if
((
settings
.
brightness
&&
settings
.
brightness
!==
0
)
||
(
settings
.
contrast
&&
settings
.
contrast
!==
0
))
{
tmp
.
brightnessContrast
(
(
settings
.
brightness
||
0
)
/
100
,
(
settings
.
contrast
||
0
)
/
100
);
}
if
(
settings
.
enable_greyscale
)
{
tmp
.
hueSaturation
(
0
,
-
1
);
}
tmp
.
update
();
return
webgl_canvas
;
}
function
handleCaman
(
canvas
,
settings
)
{
var
local_caman
;
...
...
@@ -142,7 +165,7 @@
this
.
render
(
function
()
{
// XXX canceller should be called automatically ?
canceller
();
resolve
();
resolve
(
canvas
);
});
}
catch
(
error
)
{
canceller
();
...
...
@@ -427,30 +450,57 @@
orientation
=
result
;
var
expected_width
=
settings
.
maximum_width
,
bitmap_options
,
div
;
bitmap_options
;
// If orientation is correct, return the original blob
// and size is small
// no color correction is expected
//
and
no color correction is expected
if
(((
orientation
<
2
)
||
(
8
<
orientation
))
&&
((
!
expected_width
)
||
(
original_width
<
expected_width
))
&&
((
!
expected_width
)
||
((
original_width
<
expected_width
)
&&
(
original_height
<
expected_width
)))
&&
(
!
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
)))
{
return
blob
;
}
if
((
!!
expected_width
)
&&
(
expected_width
<
original_width
))
{
bitmap_options
=
{
resizeWidth
:
expected_width
,
// resizeHeight: expected_height,
resizeQuality
:
'
high
'
};
}
// Else, transform the image
return
new
RSVP
.
Queue
(
createImageBitmap
(
blob
,
bitmap_options
))
return
new
RSVP
.
Queue
(
createImageBitmap
(
blob
))
.
push
(
function
(
bitmap
)
{
// Check if image dimension must be changed
// It is mandatory to check the bitmap info,
// as the image could be rotated
var
canvas
,
webgl_context
,
higher_dimension_key
,
higher_dimension_value
;
if
(
bitmap
.
width
<
bitmap
.
height
)
{
higher_dimension_key
=
'
resizeHeight
'
;
higher_dimension_value
=
bitmap
.
height
;
}
else
{
higher_dimension_key
=
'
resizeWidth
'
;
higher_dimension_value
=
bitmap
.
width
;
}
canvas
=
document
.
createElement
(
'
canvas
'
);
webgl_context
=
canvas
.
getContext
(
'
webgl
'
);
expected_width
=
Math
.
min
(
expected_width
||
webgl_context
.
getParameter
(
webgl_context
.
MAX_TEXTURE_SIZE
),
webgl_context
.
getParameter
(
webgl_context
.
MAX_TEXTURE_SIZE
)
-
1
);
if
((
!!
expected_width
)
&&
(
expected_width
<
higher_dimension_value
))
{
bitmap_options
=
{
resizeQuality
:
'
high
'
};
bitmap_options
[
higher_dimension_key
]
=
expected_width
;
return
createImageBitmap
(
blob
,
bitmap_options
);
}
return
bitmap
;
})
.
push
(
function
(
bitmap
)
{
var
height
=
bitmap
.
height
,
width
=
bitmap
.
width
,
canvas
=
domsugar
(
'
canvas
'
),
...
...
@@ -458,9 +508,9 @@
// Caman expect the canvas to be in a container
// in order to replace it when resizing
d
iv
=
d
omsugar
(
'
div
'
,
[
canvas
]);
domsugar
(
'
div
'
,
[
canvas
]);
if
(
4
<
orientation
&&
orientation
<
9
)
{
if
(
(
4
<
orientation
)
&&
(
orientation
<
9
)
)
{
canvas
.
width
=
height
;
canvas
.
height
=
width
;
}
else
{
...
...
@@ -499,11 +549,13 @@
ctx
.
drawImage
(
bitmap
,
0
,
0
);
if
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
)
{
return
handleCaman
(
canvas
,
settings
);
return
handleGfx
(
canvas
,
settings
);
// return handleCaman(canvas, settings);
}
return
canvas
;
})
.
push
(
function
()
{
return
promiseCanvasToBlob
(
div
.
firstElementChild
);
.
push
(
function
(
final_canvas
)
{
return
promiseCanvasToBlob
(
final_canvas
);
});
});
}
...
...
@@ -951,4 +1003,4 @@
}(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
Caman
,
FileReader
,
DataView
,
URL
));
\ No newline at end of file
FileReader
,
DataView
,
URL
,
fx
));
\ No newline at end of file
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
28b9d317
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.5
8526.37480.14609
</string>
</value>
<value>
<string>
982.5
9651.45192.29798
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1585
660747.23
</float>
<float>
1585
728228.5
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/WebSection_getDocumentScannerPrecacheManifestList.py
View file @
28b9d317
...
...
@@ -7,6 +7,8 @@ url_list = [
"cropper.min.css"
,
"cropper.min.js"
,
"caman.full.min.js"
"caman.full.min.js"
,
"glfx.js"
]
return
url_list
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/glfx.js.js
0 → 100644
View file @
28b9d317
This diff is collapsed.
Click to expand it.
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/glfx.js.xml
0 → 100644
View file @
28b9d317
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"File"
module=
"OFS.Image"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Cacheable__manager_id
</string>
</key>
<value>
<string>
must_revalidate_http_cache
</string>
</value>
</item>
<item>
<key>
<string>
__name__
</string>
</key>
<value>
<string>
glfx.js
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/javascript
</string>
</value>
</item>
<item>
<key>
<string>
precondition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
glfx.js
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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