- Added sharp library to package.json for image manipulation capabilities. - Updated pnpm-lock.yaml to include sharp dependency. - Enhanced HealthController to include provisioning queue job counts in health checks. - Improved error handling and logging in ProvisioningProcessor for better diagnostics. - Refactored order fulfillment validation to utilize new WhmcsPaymentService for payment method checks. - Updated documentation to reflect changes in the provisioning workflow and added new integration overview.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Simple SVG -> PNG converter using sharp.
|
|
* Usage: node svg2png.mjs <input.svg> <output.png> <width> <height>
|
|
*/
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import sharp from 'sharp';
|
|
|
|
async function main() {
|
|
const [,, inPath, outPath, wArg, hArg] = process.argv;
|
|
if (!inPath || !outPath || !wArg || !hArg) {
|
|
console.error('Usage: node svg2png.mjs <input.svg> <output.png> <width> <height>');
|
|
process.exit(1);
|
|
}
|
|
const width = Number(wArg);
|
|
const height = Number(hArg);
|
|
if (!width || !height) {
|
|
console.error('Width and height must be numbers');
|
|
process.exit(1);
|
|
}
|
|
|
|
const absIn = path.resolve(inPath);
|
|
const absOut = path.resolve(outPath);
|
|
const svg = await fs.readFile(absIn);
|
|
|
|
// Render with background white to avoid transparency issues in slides
|
|
const png = await sharp(svg, { density: 300 })
|
|
.resize(width, height, { fit: 'contain', background: { r: 255, g: 255, b: 255, alpha: 1 } })
|
|
.png({ compressionLevel: 9 })
|
|
.toBuffer();
|
|
|
|
await fs.mkdir(path.dirname(absOut), { recursive: true });
|
|
await fs.writeFile(absOut, png);
|
|
console.log(`Wrote ${absOut} (${width}x${height})`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('svg2png failed:', err?.message || err);
|
|
process.exit(1);
|
|
});
|
|
|