UNPKG

@genexus/web-standard-functions

Version:

GeneXus JavaScript standard functions library for web generators

30 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.flipHorizontally = void 0; const flipHorizontally = async (image) => { const img = new Image(); return new Promise((resolve, reject) => { img.onload = async function () { const canvas = document.createElement("canvas"); const context = canvas.getContext("2d"); canvas.height = img.height; canvas.width = img.width; context.scale(-1, 1); context.drawImage(img, canvas.width * -1, 0); const src = context.canvas.toDataURL(); try { const response = await fetch(src); const blob = await response.blob(); const name = image.uri.substring(image.uri.lastIndexOf("/") + 1, image.uri.length); const file = new File([blob], name.split(".")[0] + "_flipHorizontally" + "." + name.split(".")[1], { type: blob.type }); resolve(file); } catch (err) { console.log(err.name, err.message); } }; img.src = image.uri; }); }; exports.flipHorizontally = flipHorizontally; //# sourceMappingURL=flipHorizontally.js.map