mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
1 line
34 KiB
JSON
1 line
34 KiB
JSON
|
|
{"ast":null,"code":"import { Injectable, RendererFactory2 } from '@angular/core';\n\n/**\n * @fileoverview added by tsickle\n * Generated from: lib/DOC_ORIENTATION.ts\n * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc\n */\n/** @enum {number} */\nimport * as ɵngcc0 from '@angular/core';\nconst DOC_ORIENTATION = {\n Up: 1,\n Down: 3,\n Right: 6,\n Left: 8,\n UpMirrored: 2,\n DownMirrored: 4,\n LeftMirrored: 5,\n RightMirrored: 7,\n NotJpeg: -1,\n NotDefined: -2\n};\nDOC_ORIENTATION[DOC_ORIENTATION.Up] = 'Up';\nDOC_ORIENTATION[DOC_ORIENTATION.Down] = 'Down';\nDOC_ORIENTATION[DOC_ORIENTATION.Right] = 'Right';\nDOC_ORIENTATION[DOC_ORIENTATION.Left] = 'Left';\nDOC_ORIENTATION[DOC_ORIENTATION.UpMirrored] = 'UpMirrored';\nDOC_ORIENTATION[DOC_ORIENTATION.DownMirrored] = 'DownMirrored';\nDOC_ORIENTATION[DOC_ORIENTATION.LeftMirrored] = 'LeftMirrored';\nDOC_ORIENTATION[DOC_ORIENTATION.RightMirrored] = 'RightMirrored';\nDOC_ORIENTATION[DOC_ORIENTATION.NotJpeg] = 'NotJpeg';\nDOC_ORIENTATION[DOC_ORIENTATION.NotDefined] = 'NotDefined';\n\n/**\n * @fileoverview added by tsickle\n * Generated from: lib/image-compress.ts\n * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc\n */\nclass ImageCompress {\n /**\n * Get the correct Orientation value from tags, in order to write correctly in our canvas\n * @param {?} file\n * @param {?} callback\n * @return {?}\n */\n static getOrientation(file, callback) {\n /** @type {?} */\n const reader = new FileReader();\n try {\n reader.onload =\n /**\n * @param {?} $event\n * @return {?}\n */\n function ($event) {\n /** @type {?} */\n const view = new DataView( /** @type {?} */reader.result);\n if (view.getUint16(0, false) !== 0xFFD8) {\n return callback(-2);\n }\n /** @type {?} */\n const length = view.byteLength;\n /** @type {?} */\n let offset = 2;\n while (offset < length) {\n /** @type {?} */\n const marker = view.getUint16(offset, false);\n offset += 2;\n if (marker === 0xFFE1) {\n if (view.getUint32(offset += 2, false) !== 0x45786966) {\n return callback(-1);\n }\n /** @type {?} */\n const little = view.getUint16(offset += 6, false) === 0x4949;\n offset += view.getUint32(offset + 4, little);\n /** @type {?} */\n const tags = view.getUint16(offset, little);\n offset += 2;\n for (let i = 0; i < tags; i++) {\n if (view.getUint16(offset + i * 12, little) === 0x0112) {\n return callback(view.getUint16(offset + i * 12 + 8, little));\n }\n }\n } else if ((marker & 0xFF00) !== 0xFF00) {\n break;\n } else {\n offset += view.getUint16(offset, false);\n }\n }\n return callback(-1);\n };\n reader.readAsArrayBuffer(file);\n } catch (e) {\n return callback(0);\n }\n }\n /**\n * return a promise with the new image data and image orientation\n * @param {?} render\n * @return {?}\n */\n static uploadFile(render) {\n /** @type {?} */\n const promise = new Promise(\n /**\n * @param {?} resolve\n * @param {?} reject\n * @return {?}\n */\n function (resolve, reject) {\n var _a, _b;\n /** @type {?} */\n const inputElement = render.createElement('input');\n // should be fix the problem for safari/ios\n (_b = (_a = document.getElementsByTagName('body')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.append(inputElement);\n render.setStyle(inputElement, 'display', 'none');\n render.setProperty(inputElement, 'type', 'file');\n render.setProperty(inputElement, 'accept', 'image/*');\n render.listen(inputEle
|