/*Created on 10/27/2023 21:01:45.*/ const sharp = require('sharp'); const fs = require('fs'); class FHSharpTestLib { /** * @param {String} resPath * @returns {Promise.} */ async fHSharpTest( resPath ) { console.log("input start"); console.log(resPath); console.log("input end"); const baseFile = resPath.concat("canvas.jpg"); console.log("In main"); const svgPostLine1Height = 50; const svgPostLine2Height = 50; const line1px = "42px"; const line2px = "36px"; const line1HexVal = "#595959"; const line2HexVal = "#ff0000"; const line1Style = "bold"; const line2Style = "normal"; const postLine1 = "This is Line 1. it is bold and in gray"; const postLine2 = "This is Line 2. it is in normal and in red"; const svgLineWidth = 512; const rightTextOffset = 25; const fontUrl = resPath.concat("fonts/arial.ttf"); const svgPostLine1 = ` ${postLine1} `; const svgPostLine2 = ` ${postLine2} `; console.log(svgPostLine1); console.log(svgPostLine2); const svgLine1 = Buffer.from(svgPostLine1); const svgLine2 = Buffer.from(svgPostLine2); try { return sharp(baseFile) .composite([ { input: svgLine1, top: 200, left: 200 }, { input: svgLine2, top: 400, left: 200 } ]) .toBuffer(); } catch (error) { console.log( error); } } } Backendless.ServerCode.addService( FHSharpTestLib );