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
Frederic Thoma
erp5
Commits
82c40e30
Commit
82c40e30
authored
Sep 07, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: use load-image library to bypass chrome canvas transformation issue
parent
db159266
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
65 deletions
+55
-65
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
+15
-60
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
-1
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/load-image.all.min.js.js
...rtal_skins/erp5_document_scanner/load-image.all.min.js.js
+1
-0
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/load-image.all.min.js.xml
...tal_skins/erp5_document_scanner/load-image.all.min.js.xml
+32
-0
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.html
View file @
82c40e30
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
<script
type=
"text/javascript"
src=
"domsugar.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=
"caman.full.min.js"
></script>
<script
type=
"text/javascript"
src=
"glfx.js"
></script>
<script
type=
"text/javascript"
src=
"glfx.js"
></script>
<script
type=
"text/javascript"
src=
"load-image.all.min.js"
></script>
<script
type=
"text/javascript"
src=
"gadget_document_scanner.js"
></script>
<script
type=
"text/javascript"
src=
"gadget_document_scanner.js"
></script>
<title>
Gadget Document Scanner
</title>
<title>
Gadget Document Scanner
</title>
</head>
</head>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.xml
View file @
82c40e30
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
98
2.61373.37397.17954
</string>
</value>
<value>
<string>
98
3.7362.49324.10547
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -260,7 +260,7 @@
...
@@ -260,7 +260,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15
85899899.78
</float>
<float>
15
99236057.62
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
82c40e30
/*jslint indent: 2, unparam: true, bitwise: true */
/*jslint indent: 2, unparam: true, bitwise: true */
/*global rJS, RSVP, window, document, navigator, Cropper, Promise, JSON, jIO,
/*global rJS, RSVP, window, document, navigator, Cropper, Promise, JSON, jIO,
promiseEventListener, domsugar, createImageBitmap, FormData, Caman,
promiseEventListener, domsugar, createImageBitmap, FormData, Caman,
FileReader, DataView, URL, fx*/
FileReader, DataView, URL, fx
, loadImage
*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
caman
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
caman
,
FileReader
,
DataView
,
URL
,
fx
)
{
FileReader
,
DataView
,
URL
,
fx
)
{
...
@@ -528,8 +528,7 @@
...
@@ -528,8 +528,7 @@
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
orientation
=
result
;
orientation
=
result
;
var
expected_width
=
settings
.
maximum_width
,
var
expected_width
=
settings
.
maximum_width
;
bitmap_options
;
// If orientation is correct, return the original blob
// If orientation is correct, return the original blob
// and size is small
// and size is small
// and no color correction is expected
// and no color correction is expected
...
@@ -550,13 +549,19 @@
...
@@ -550,13 +549,19 @@
var
canvas
,
var
canvas
,
webgl_context
,
webgl_context
,
higher_dimension_key
,
higher_dimension_key
,
higher_dimension_value
;
higher_dimension_value
,
load_image_options
=
{
meta
:
false
,
orientation
:
true
,
canvas
:
true
,
imageSmoothingQuality
:
'
high
'
};
if
(
bitmap
.
width
<
bitmap
.
height
)
{
if
(
bitmap
.
width
<
bitmap
.
height
)
{
higher_dimension_key
=
'
resize
Height
'
;
higher_dimension_key
=
'
max
Height
'
;
higher_dimension_value
=
bitmap
.
height
;
higher_dimension_value
=
bitmap
.
height
;
}
else
{
}
else
{
higher_dimension_key
=
'
resize
Width
'
;
higher_dimension_key
=
'
max
Width
'
;
higher_dimension_value
=
bitmap
.
width
;
higher_dimension_value
=
bitmap
.
width
;
}
}
...
@@ -569,64 +574,14 @@
...
@@ -569,64 +574,14 @@
);
);
if
((
!!
expected_width
)
&&
(
expected_width
<
higher_dimension_value
))
{
if
((
!!
expected_width
)
&&
(
expected_width
<
higher_dimension_value
))
{
bitmap_options
=
{
load_image_options
[
higher_dimension_key
]
=
expected_width
;
resizeQuality
:
'
high
'
};
bitmap_options
[
higher_dimension_key
]
=
expected_width
;
return
createImageBitmap
(
blob
,
bitmap_options
);
}
}
return
bitmap
;
return
loadImage
(
blob
,
load_image_options
)
;
})
})
.
push
(
function
(
bitmap
)
{
.
push
(
function
(
data
)
{
var
height
=
bitmap
.
height
,
var
canvas
=
data
.
image
;
width
=
bitmap
.
width
,
canvas
=
domsugar
(
'
canvas
'
),
ctx
;
// Caman expect the canvas to be in a container
// in order to replace it when resizing
domsugar
(
'
div
'
,
[
canvas
]);
if
((
4
<
orientation
)
&&
(
orientation
<
9
))
{
canvas
.
width
=
height
;
canvas
.
height
=
width
;
}
else
{
canvas
.
width
=
width
;
canvas
.
height
=
height
;
}
ctx
=
canvas
.
getContext
(
'
2d
'
);
// transform context before drawing image
switch
(
orientation
)
{
case
2
:
ctx
.
transform
(
-
1
,
0
,
0
,
1
,
width
,
0
);
break
;
case
3
:
ctx
.
transform
(
-
1
,
0
,
0
,
-
1
,
width
,
height
);
break
;
case
4
:
ctx
.
transform
(
1
,
0
,
0
,
-
1
,
0
,
height
);
break
;
case
5
:
ctx
.
transform
(
0
,
1
,
1
,
0
,
0
,
0
);
break
;
case
6
:
ctx
.
transform
(
0
,
1
,
-
1
,
0
,
height
,
0
);
break
;
case
7
:
ctx
.
transform
(
0
,
-
1
,
-
1
,
0
,
height
,
width
);
break
;
case
8
:
ctx
.
transform
(
0
,
-
1
,
1
,
0
,
0
,
width
);
break
;
default
:
break
;
}
ctx
.
drawImage
(
bitmap
,
0
,
0
);
if
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
)
{
if
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
)
{
return
handleGfx
(
canvas
,
settings
);
return
handleGfx
(
canvas
,
settings
);
// return handleCaman(canvas, settings);
// return handleCaman(canvas, settings);
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
82c40e30
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
98
3.14351.3372.41932
</string>
</value>
<value>
<string>
98
6.29418.46329.12509
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15
86942462.17
</float>
<float>
15
99470361.92
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/WebSection_getDocumentScannerPrecacheManifestList.py
View file @
82c40e30
...
@@ -7,7 +7,8 @@ url_list = [
...
@@ -7,7 +7,8 @@ url_list = [
"cropper.css"
,
"cropper.css"
,
"cropper.js"
,
"cropper.js"
,
"caman.full.min.js"
,
"caman.full.min.js"
,
"glfx.js"
"glfx.js"
,
"load-image.all.min.js"
]
]
return
url_list
return
url_list
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/load-image.all.min.js.js
0 → 100644
View file @
82c40e30
This diff is collapsed.
Click to expand it.
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/load-image.all.min.js.xml
0 → 100644
View file @
82c40e30
<?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>
load-image.all.min.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>
load-image.all.min.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