update
This commit is contained in:
30
APP/nexus-remote/node_modules/png-to-ico/lib/png.js
generated
vendored
Normal file
30
APP/nexus-remote/node_modules/png-to-ico/lib/png.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { promises as pfs } from "node:fs";
|
||||
import { PNG } from "pngjs";
|
||||
import Resize from "./resize.js";
|
||||
|
||||
async function readPNG(filepath) {
|
||||
try {
|
||||
let data;
|
||||
if (Buffer.isBuffer(filepath)) {
|
||||
data = filepath;
|
||||
} else {
|
||||
data = await pfs.readFile(filepath);
|
||||
}
|
||||
|
||||
return PNG.sync.read(data);
|
||||
} catch (err) {
|
||||
throw new Error(`${filepath} is not or a valid PNG file.`);
|
||||
}
|
||||
}
|
||||
|
||||
function resize(src, width, height, interpolation = "bicubicInterpolation") {
|
||||
const result = createPNG(width, height);
|
||||
Resize[interpolation](src, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPNG(width = 256, height = 256) {
|
||||
return new PNG({ width, height });
|
||||
}
|
||||
|
||||
export { readPNG, resize };
|
||||
Reference in New Issue
Block a user