MCPcopy Create free account
hub / github.com/api-platform/website / createWallpaper

Function createWallpaper

pwa/prebuild.ts:13–31  ·  view source on GitHub ↗
(
  inputDirectory: string,
  outputDirectory: string,
  file: string,
  width: number,
  height: number
)

Source from the content-addressed store, hash-verified

11const { current, versions } = require("./consts");
12
13export async function createWallpaper(
14 inputDirectory: string,
15 outputDirectory: string,
16 file: string,
17 width: number,
18 height: number
19) {
20 const outputFile = `${outputDirectory}/${
21 path.parse(file).name
22 }-${width}-${height}.jpg`;
23 if (fs.existsSync(outputFile)) {
24 // File exists in path
25 } else {
26 await sharp(`${inputDirectory}/${file}`)
27 .resize(width, height, { fit: "cover" })
28 .jpeg({ mozjpeg: true, quality: 100 })
29 .toFile(outputFile);
30 }
31}
32
33async function createWallpapers() {
34 const inputDirectory = path.join(process.cwd(), "data", "wallpapers");

Callers 1

createWallpapersFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected