Skip to content

Commit

Permalink
Merge pull request #1452 from flexion/8537-issue-with-scanner
Browse files Browse the repository at this point in the history
8537 issue with scanner
  • Loading branch information
mmarcotte authored Jul 6, 2021
2 parents 9847e1c + fce1271 commit 153ceca
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 20 deletions.
44 changes: 39 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"http-aws-es": "^6.0.0",
"husky": "^6.0.0",
"i": "^0.3.6",
"image-blob-reduce": "^3.0.1",
"jest": "^26.6.3",
"joi": "^17.4.0",
"jsdoc": "^3.6.7",
Expand Down Expand Up @@ -129,7 +130,6 @@
"sanitize-filename": "^1.6.3",
"sass": "^1.35.1",
"sass-loader": "^12.1.0",
"simple-image-resize": "^1.0.1",
"stream-browserify": "^3.0.0",
"style-loader": "^2.0.0",
"stylelint": "^13.13.1",
Expand Down
19 changes: 13 additions & 6 deletions shared/src/persistence/dynamsoft/getScannerMockInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@ exports.getScannerInterface = () => {

return Promise.all(promises)
.then(async blobs => {
const blobBuffers = [];
const COVER_SHEET_WIDTH_IN_PX = 866;

const scaledDownBlobs = await Promise.all(
blobs.map(blob =>
applicationContext
.getReduceImageBlob()
.toBlob(blob, { max: COVER_SHEET_WIDTH_IN_PX }),
),
);

const blobBuffers = await Promise.all(
scaledDownBlobs.map(applicationContext.convertBlobToUInt8Array),
);

for (let blob of blobs) {
blobBuffers.push(
new Uint8Array(await new Response(blob).arrayBuffer()),
);
}
response.scannedBuffer = blobBuffers;
DWObject.RemoveAllImages();
return response;
Expand Down
13 changes: 5 additions & 8 deletions web-client/src/applicationContext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import ImageBlobReduce from 'image-blob-reduce';
const reduce = ImageBlobReduce({
pica: ImageBlobReduce.pica({ features: ['js'] }),
});
import { BroadcastChannel } from 'broadcast-channel';
import {
Case,
Expand Down Expand Up @@ -42,7 +46,6 @@ import { getCropBox } from '../../shared/src/business/utilities/getCropBox';
import { getDocumentTitleWithAdditionalInfo } from '../../shared/src/business/utilities/getDocumentTitleWithAdditionalInfo';
import { getStampBoxCoordinates } from '../../shared/src/business/utilities/getStampBoxCoordinates';
import { getUserPendingEmailStatusInteractor } from '../../shared/src/proxies/users/getUserPendingEmailStatusProxy';
import { resizeImage } from 'simple-image-resize';
import { setupPdfDocument } from '../../shared/src/business/utilities/setupPdfDocument';
const {
getDocQcSectionForUser,
Expand Down Expand Up @@ -615,13 +618,7 @@ const applicationContext = {
};
},
getPublicSiteUrl,
getReduceImageBlob: () => ({
toBlob: (blob, { max }) => {
return resizeImage(new File([blob], 'blob'), {
maxWidth: max,
});
},
}),
getReduceImageBlob: () => reduce,
getScanner: async () => {
if (process.env.NO_SCANNER) {
const scanner = await import(
Expand Down

0 comments on commit 153ceca

Please sign in to comment.