Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/avatar-editor/src/canvas-tool/ |
Upload File : |
import {Dom, Event, Loc} from 'main.core'; import {ImageType, CanvasDefault} from './canvas-default'; import CanvasLoader from './canvas-loader'; export default class CanvasMaster extends CanvasDefault { #fileName: ?String; load(file): Promise { this.emit('onLoad'); this.#fileName = null; return new Promise((resolve, reject) => { this.reset(); CanvasLoader.loadFile( file, (imageNode) => { this.#fileName = imageNode.name; this.set(imageNode); resolve(); }, () => { this.emit('onError', Loc.getMessage('JS_AVATAR_EDITOR_ERROR_IMAGE_DEPLOYING')); reject(); } ); }); } #applyNameAndExtensionToBlob(result: Blob): Blob { result.name = this.#fileName || 'image'; let ext = result.name.split('.').pop().toLowerCase(); ext = (ext === result.name ? '' : ext); if (result.type === 'image/png' && ext !== 'png') { if ('jpg,bmp,jpeg,jpe,gif,png,webp'.lastIndexOf(ext) > 0) { result.name = result.name.substr(0, result.name.lastIndexOf('.')); } result.name = [(result.name || 'image'), 'png'].join('.'); } return result; } getBlob(): Promise { return new Promise((resolve, reject) => { this.packBlob() .then((blob) => { this.#applyNameAndExtensionToBlob(blob); resolve({blob}); }) .catch(reject); }); } }