Commit 37c35b8c authored by Romain Courteaud's avatar Romain Courteaud

erp5_document_scanner: handle caman error

parent c5496e75
......@@ -126,9 +126,10 @@
caman.Store.flush(true);
}
return new Promise(function (resolve) {
return new Promise(function (resolve, reject) {
// XXX the correct usage is `new Caman()` but the library does not support it
local_caman = caman(canvas, null, function () {
try {
if (settings.brightness && settings.brightness !== 0) {
this.brightness(settings.brightness);
}
......@@ -143,6 +144,10 @@
canceller();
resolve();
});
} catch (error) {
canceller();
reject(error);
}
});
return local_caman;
}, canceller);
......@@ -480,10 +485,13 @@
return blob;
}
var canvas;
var div;
return new RSVP.Queue(createImageBitmap(blob))
.push(function (bitmap) {
canvas = domsugar('canvas');
var canvas = domsugar('canvas');
// Caman expect the canvas to be in a container
// in order to replace it when resizing
div = domsugar('div', [canvas]);
canvas.width = bitmap.width;
canvas.height = bitmap.height;
......@@ -492,7 +500,7 @@
return handleCaman(canvas, settings);
})
.push(function () {
return promiseCanvasToBlob(canvas);
return promiseCanvasToBlob(div.firstElementChild);
});
}
......@@ -529,7 +537,10 @@
return image_capture.getPhotoCapabilities();
})
.push(function (capabilities) {
return image_capture.takePhoto({imageWidth: capabilities.imageWidth.max});
return image_capture.takePhoto({
imageWidth: capabilities.imageWidth.max,
imageHeight: capabilities.imageHeight.max
});
})
.push(function (blob) {
gadget.detached_promise_dict.media_stream.cancel('Not needed anymore, as captured');
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.57254.54695.8721</string> </value>
<value> <string>982.58248.12377.39526</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1585584566.97</float>
<float>1585644055.38</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment