Skip to content

chore: upgrade jimp #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"degit": "^2.8.4",
"dotenv": "^16.4.5",
"esbuild": "^0.20.2",
"jimp": "^0.22.12",
"jimp": "^1.1.1",
"lightningcss": "^1.25.1",
"magic-string": "^0.30.10",
"marked": "^12.0.2",
Expand Down
19 changes: 9 additions & 10 deletions apps/svelte.dev/scripts/get_contributors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import 'dotenv/config';
import Jimp from 'jimp';
import { Jimp } from 'jimp';
import { stat, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -46,27 +46,26 @@ try {
.sort((a, b) => b.contributions - a.contributions)
.slice(0, MAX);

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

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

const image_data = await fetch(author.avatar_url);
const buffer = await image_data.arrayBuffer();
const image = await Jimp.fromBuffer(buffer);

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

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

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

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

Expand Down
21 changes: 11 additions & 10 deletions apps/svelte.dev/scripts/get_donors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import 'dotenv/config';
import Jimp from 'jimp';
import { Jimp } from 'jimp';
import { stat, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -42,25 +42,26 @@ try {
try {
const image_data = await fetch(backer.image);
const buffer = await image_data.arrayBuffer();
// @ts-ignore
const image = await Jimp.read(buffer);
image.resize(SIZE, SIZE);
const image = await Jimp.fromBuffer(buffer);

image.resize({ w: SIZE, h: SIZE });

included.push({ backer, image });
} catch (err) {
console.log(`Skipping ${backer.name}: no image data`);
}
}

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

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

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

Expand Down
Loading
Loading