Skip to content

Commit df643cd

Browse files
authored
chore: upgrade jimp (#68)
1 parent ca81e1d commit df643cd

File tree

4 files changed

+268
-453
lines changed

4 files changed

+268
-453
lines changed

apps/svelte.dev/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"degit": "^2.8.4",
7373
"dotenv": "^16.4.5",
7474
"esbuild": "^0.20.2",
75-
"jimp": "^0.22.12",
75+
"jimp": "^1.1.1",
7676
"lightningcss": "^1.25.1",
7777
"magic-string": "^0.30.10",
7878
"marked": "^12.0.2",

apps/svelte.dev/scripts/get_contributors.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
import 'dotenv/config';
3-
import Jimp from 'jimp';
3+
import { Jimp } from 'jimp';
44
import { stat, writeFile } from 'node:fs/promises';
55
import { dirname } from 'node:path';
66
import { fileURLToPath } from 'node:url';
@@ -46,27 +46,26 @@ try {
4646
.sort((a, b) => b.contributions - a.contributions)
4747
.slice(0, MAX);
4848

49-
const sprite = new Jimp(SIZE * authors.length, SIZE);
49+
const sprite = new Jimp({ width: SIZE * authors.length, height: SIZE });
5050

5151
for (let i = 0; i < authors.length; i += 1) {
5252
const author = authors[i];
5353
console.log(`${i + 1} / ${authors.length}: ${author.login}`);
5454

5555
const image_data = await fetch(author.avatar_url);
5656
const buffer = await image_data.arrayBuffer();
57+
const image = await Jimp.fromBuffer(buffer);
5758

58-
// @ts-ignore
59-
const image = await Jimp.read(buffer);
60-
image.resize(SIZE, SIZE);
59+
image.resize({ w: SIZE, h: SIZE });
6160

6261
sprite.composite(image, i * SIZE, 0);
6362
}
6463

65-
await sprite
66-
.quality(80)
67-
.writeAsync(
68-
fileURLToPath(new URL(`../src/routes/_home/Supporters/contributors.jpg`, import.meta.url))
69-
);
64+
await sprite.write(
65+
// @ts-expect-error
66+
fileURLToPath(new URL(`../src/routes/_home/Supporters/contributors.jpg`, import.meta.url)),
67+
{ quality: 80 }
68+
);
7069

7170
const str = `[\n\t${authors.map((a) => `'${a.login}'`).join(',\n\t')}\n]`;
7271

apps/svelte.dev/scripts/get_donors.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
import 'dotenv/config';
3-
import Jimp from 'jimp';
3+
import { Jimp } from 'jimp';
44
import { stat, writeFile } from 'node:fs/promises';
55
import { dirname } from 'node:path';
66
import { fileURLToPath } from 'node:url';
@@ -42,25 +42,26 @@ try {
4242
try {
4343
const image_data = await fetch(backer.image);
4444
const buffer = await image_data.arrayBuffer();
45-
// @ts-ignore
46-
const image = await Jimp.read(buffer);
47-
image.resize(SIZE, SIZE);
45+
const image = await Jimp.fromBuffer(buffer);
46+
47+
image.resize({ w: SIZE, h: SIZE });
48+
4849
included.push({ backer, image });
4950
} catch (err) {
5051
console.log(`Skipping ${backer.name}: no image data`);
5152
}
5253
}
5354

54-
const sprite = new Jimp(SIZE * included.length, SIZE);
55+
const sprite = new Jimp({ width: SIZE * included.length, height: SIZE });
5556
for (let i = 0; i < included.length; i += 1) {
5657
sprite.composite(included[i].image, i * SIZE, 0);
5758
}
5859

59-
await sprite
60-
.quality(80)
61-
.writeAsync(
62-
fileURLToPath(new URL(`../src/routes/_home/Supporters/donors.jpg`, import.meta.url))
63-
);
60+
await sprite.write(
61+
// @ts-expect-error
62+
fileURLToPath(new URL(`../src/routes/_home/Supporters/donors.jpg`, import.meta.url)),
63+
{ quality: 80 }
64+
);
6465

6566
const str = `[\n\t${included.map((a) => `${JSON.stringify(a.backer.name)}`).join(',\n\t')}\n]`;
6667

0 commit comments

Comments
 (0)