import { createCanvas } from 'canvas'; import { initializeCanvas } from './index'; import { decodeJpeg } from './jpeg'; function createCanvasFromData(data) { var canvas = createCanvas(100, 100); try { var context_1 = canvas.getContext('2d'); var imageData = decodeJpeg(data, function (w, h) { return context_1.createImageData(w, h); }); canvas.width = imageData.width; canvas.height = imageData.height; context_1.putImageData(imageData, 0, 0); } catch (e) { console.error('JPEG decompression error', e.message); } return canvas; } initializeCanvas(createCanvas, createCanvasFromData); export function initialize() { initializeCanvas(createCanvas, createCanvasFromData); } //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluaXRpYWxpemVDYW52YXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLFFBQVEsQ0FBQztBQUN0QyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxTQUFTLENBQUM7QUFDM0MsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLFFBQVEsQ0FBQztBQUVwQyxTQUFTLG9CQUFvQixDQUFDLElBQWdCO0lBQzdDLElBQU0sTUFBTSxHQUFHLFlBQVksQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDLENBQUM7SUFFdEMsSUFBSTtRQUNILElBQU0sU0FBTyxHQUFHLE1BQU0sQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFFLENBQUM7UUFDekMsSUFBTSxTQUFTLEdBQUcsVUFBVSxDQUFDLElBQUksRUFBRSxVQUFDLENBQUMsRUFBRSxDQUFDLElBQUssT0FBQSxTQUFPLENBQUMsZUFBZSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBN0IsQ0FBNkIsQ0FBQyxDQUFDO1FBQzVFLE1BQU0sQ0FBQyxLQUFLLEdBQUcsU0FBUyxDQUFDLEtBQUssQ0FBQztRQUMvQixNQUFNLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxNQUFNLENB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