Skip to content

Commit 233ef08

Browse files
matmenclaude
andcommitted
README, keywords, issue template, example with options objects
- README: lossy WebP encoding is what 3.0 removed, the package is about 160 kB, trim and the animation optimization in the features - keywords for the formats and features added since 1.x - the bug report asks for the ImageScript and runtime version - the README example uses options objects (same image) - .gitignore without entries of the old toolchain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
1 parent 2a0feda commit 233ef08

5 files changed

Lines changed: 49 additions & 45 deletions

File tree

‎.github/ISSUE_TEMPLATE/bug_report.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ labels: bug
77
---
88

99
**Describe the bug**
10-
A clear and concise description of what the bug is.
10+
A clear and concise description of what the bug is. If it's about a specific image, please attach it.
1111

1212
**To Reproduce**
1313
Steps to reproduce the behavior:
@@ -20,9 +20,9 @@ A clear and concise description of what you expected to happen.
2020
If applicable, add screenshots to help explain your problem.
2121

2222
**Platform:**
23-
- OS: [e.g. iOS, Windows]
24-
- Environment [e.g. Chrome, Firefox, NodeJS, Deno]
25-
- Version [e.g. 1.0.1, 1.1.20]
23+
- ImageScript version: [e.g. 3.1.0]
24+
- Runtime and version: [e.g. Node.js 24.3, Bun 1.3, Chrome 141]
25+
- OS: [e.g. Windows 11, Ubuntu 24.04]
2626

2727
**Additional context**
2828
Add any other context about the problem here.

‎.gitignore‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
old/
2-
.idea/
3-
coverage/
4-
.DS_Store
5-
.nyc_output/
61
node_modules/
72
dist/
83
docs/
4+
.idea/
5+
.DS_Store

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
**ImageScript** is a zero-dependency alternative to common JavaScript bitmap image manipulation tools. Every codec and
1111
renderer is written in TypeScript: no WebAssembly, no native binaries, no npm dependencies, no install scripts. The
12-
package is about 140 kB (compressed) and runs in Node.js 22.13 or newer (including Alpine/musl, ARM and bundled
12+
package is about 160 kB (compressed) and runs in Node.js 22.13 or newer (including Alpine/musl, ARM and bundled
1313
serverless functions), Deno, Bun and browsers. It works with both `import` and `require()`, type definitions are included.
1414

1515
```sh
@@ -38,7 +38,8 @@ deno add jsr:@matmen/imagescript # Deno (npm:imagescript works too)
3838
- Image manipulation functions ([crop](https://imagescript.matmen.dev/classes/Image.html#crop)
3939
, [rotate](https://imagescript.matmen.dev/classes/Image.html#rotate)
4040
, [cropCircle](https://imagescript.matmen.dev/classes/Image.html#cropcircle)
41-
, [roundCorners](https://imagescript.matmen.dev/classes/Image.html#roundcorners), ...)
41+
, [roundCorners](https://imagescript.matmen.dev/classes/Image.html#roundcorners)
42+
, [trim](https://imagescript.matmen.dev/classes/Image.html#trim), ...)
4243
- Filters and color adjustments ([blur](https://imagescript.matmen.dev/classes/Image.html#blur)
4344
, [sharpen](https://imagescript.matmen.dev/classes/Image.html#sharpen)
4445
, [brightness](https://imagescript.matmen.dev/classes/Image.html#brightness)
@@ -53,7 +54,7 @@ deno add jsr:@matmen/imagescript # Deno (npm:imagescript works too)
5354
and [TGAs](https://imagescript.matmen.dev/classes/Image.html#encodetga)
5455
- Encoding animations as [GIF](https://imagescript.matmen.dev/classes/Animation.html#encodegif),
5556
[APNG](https://imagescript.matmen.dev/classes/Animation.html#encodeapng) and lossless
56-
[WebP](https://imagescript.matmen.dev/classes/Animation.html#encodewebp)
57+
[WebP](https://imagescript.matmen.dev/classes/Animation.html#encodewebp), storing only what changes from frame to frame
5758

5859
---
5960

@@ -77,7 +78,7 @@ const { Image } = require('imagescript');
7778
All coordinates are 0-based, `(0, 0)` is the top left pixel.
7879

7980
A bigger example is the [README image generation](https://github.com/matmen/ImageScript/blob/master/tests/readme.js).
80-
Upgrading from 1.x? Version 3 has breaking changes (0-based coordinates, removed WebP encoding, Node.js 22.13+, ...),
81+
Upgrading from 1.x? Version 3 has breaking changes (0-based coordinates, removed lossy WebP encoding, Node.js 22.13+, ...),
8182
see the [changelog](https://github.com/matmen/ImageScript/blob/master/CHANGELOG.md). There is no 2.x release, the number was skipped because of the old experimental
8283
`imagescript/v2` API.
8384

‎package.json‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@
4747
"bitmap",
4848
"gif",
4949
"picture",
50-
"thumbnail"
50+
"thumbnail",
51+
"webp",
52+
"apng",
53+
"tiff",
54+
"tga",
55+
"animation",
56+
"text rendering",
57+
"font"
5158
],
5259
"author": "Mathis Mensing <mathis@matmen.dev>",
5360
"license": "(AGPL-3.0-or-later OR MIT)",

‎tests/readme.js‎

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,88 +21,87 @@ const samePixels = require('./util/pixels');
2121
const backgroundPattern = await Image.renderSVG(backgroundSVG);
2222
for (let xOffset = 0; xOffset < image.width; xOffset += backgroundPattern.width) {
2323
for (let yOffset = 0; yOffset < image.height; yOffset += backgroundPattern.height) {
24-
image.composite(backgroundPattern, xOffset, yOffset);
24+
image.composite(backgroundPattern, {x: xOffset, y: yOffset});
2525
}
2626
}
2727

2828
const avatarBG = new Image(200 + 16, 200 + 16);
2929
const avatarGradient = Image.gradient({0: 0x00ffffff, 1: 0x0080ffff});
3030
avatarBG.fill((x, y) => avatarGradient((x + y) / (avatarBG.width + avatarBG.height)));
31-
image.composite(avatarBG.cropCircle(), 0.05 * image.width, 0.05 * image.height);
31+
image.composite(avatarBG.cropCircle(), {x: 0.05 * image.width, y: 0.05 * image.height});
3232

3333
const avatar = await Image.decode(avatarBinary);
34-
image.composite(avatar.resize(200, 200).cropCircle(), 0.05 * image.width + 8, 0.05 * image.height + 8);
34+
image.composite(avatar.resize(200, 200).cropCircle(), {x: 0.05 * image.width + 8, y: 0.05 * image.height + 8});
3535

36-
const username = await Image.renderText(font, 64, 'matmen', 0xffffffff);
37-
image.composite(username, 0.3 * image.width, 0.05 * image.height);
36+
const username = await Image.renderText(font, 64, 'matmen', {color: 0xffffffff});
37+
image.composite(username, {x: 0.3 * image.width, y: 0.05 * image.height});
3838

3939
image.drawBox(0.3 * image.width, 0.05 * image.height + username.height, username.width, 3, 0x808080ff);
4040

41-
const discriminator = await Image.renderText(font, 48, '#9984', 0xd0d0d0ff);
42-
image.composite(discriminator, 0.3 * image.width, 0.05 * image.height + username.height);
41+
const discriminator = await Image.renderText(font, 48, '#9984', {color: 0xd0d0d0ff});
42+
image.composite(discriminator, {x: 0.3 * image.width, y: 0.05 * image.height + username.height});
4343

4444
// Global XP
4545
{
4646
const xpBarBackground = new Image(0.9 * image.width, 0.05 * image.height);
4747
xpBarBackground.fill(0xa0a0a0ff);
48-
image.composite(xpBarBackground.roundCorners(16), 0.05 * image.width, 0.5 * image.height);
48+
image.composite(xpBarBackground.roundCorners(16), {x: 0.05 * image.width, y: 0.5 * image.height});
4949

5050
const xpBar = new Image(69 / 420 * xpBarBackground.width, 0.05 * image.height);
5151
const xpGradient = Image.gradient({0: 0x0080ffff, .8: 0x00ffffff, 1: 0x00ff80ff});
5252
xpBar.fill(x => xpGradient(x / xpBarBackground.width));
53-
image.composite(xpBar.roundCorners(16), 0.05 * image.width, 0.5 * image.height);
53+
image.composite(xpBar.roundCorners(16), {x: 0.05 * image.width, y: 0.5 * image.height});
5454

55-
const xpText = await Image.renderText(font, 32, '69/420', 0xff);
56-
image.composite(xpText, 0.05 * image.width + xpBarBackground.width / 2 - xpText.width / 2, 0.5 * image.height + xpBarBackground.height / 2 - xpText.height / 2);
55+
const xpText = await Image.renderText(font, 32, '69/420', {color: 0xff});
56+
image.composite(xpText, {x: 0.05 * image.width + xpBarBackground.width / 2 - xpText.width / 2, y: 0.5 * image.height + xpBarBackground.height / 2 - xpText.height / 2});
5757

58-
const levelText = await Image.renderText(font, 32, 'Level 3', 0xffffffff);
59-
image.composite(levelText, 0.05 * image.width + xpBarBackground.width - levelText.width, 0.5 * image.height - levelText.height);
58+
const levelText = await Image.renderText(font, 32, 'Level 3', {color: 0xffffffff});
59+
image.composite(levelText, {x: 0.05 * image.width + xpBarBackground.width - levelText.width, y: 0.5 * image.height - levelText.height});
6060

61-
const xpKindText = await Image.renderText(font, 32, 'Global XP', 0xffffffff);
62-
image.composite(xpKindText, 0.05 * image.width, 0.5 * image.height - levelText.height);
61+
const xpKindText = await Image.renderText(font, 32, 'Global XP', {color: 0xffffffff});
62+
image.composite(xpKindText, {x: 0.05 * image.width, y: 0.5 * image.height - levelText.height});
6363
}
6464

6565
// Server XP
6666
{
6767
const xpBarBackground = new Image(0.9 * image.width, 0.05 * image.height);
6868
xpBarBackground.fill(0xa0a0a0ff);
69-
image.composite(xpBarBackground.roundCorners(16), 0.05 * image.width, 0.65 * image.height);
69+
image.composite(xpBarBackground.roundCorners(16), {x: 0.05 * image.width, y: 0.65 * image.height});
7070

7171
const xpBar = new Image(75 / 100 * xpBarBackground.width, 0.05 * image.height);
7272
const xpGradient = Image.gradient({0: 0x0080ffff, .8: 0x00ffffff, 1: 0x00ff80ff});
7373
xpBar.fill(x => xpGradient(x / xpBarBackground.width));
74-
image.composite(xpBar.roundCorners(16), 0.05 * image.width, 0.65 * image.height);
74+
image.composite(xpBar.roundCorners(16), {x: 0.05 * image.width, y: 0.65 * image.height});
7575

76-
const xpText = await Image.renderText(font, 32, '75/100', 0xff);
77-
image.composite(xpText, 0.05 * image.width + xpBarBackground.width / 2 - xpText.width / 2, 0.65 * image.height + xpBarBackground.height / 2 - xpText.height / 2);
76+
const xpText = await Image.renderText(font, 32, '75/100', {color: 0xff});
77+
image.composite(xpText, {x: 0.05 * image.width + xpBarBackground.width / 2 - xpText.width / 2, y: 0.65 * image.height + xpBarBackground.height / 2 - xpText.height / 2});
7878

79-
const levelText = await Image.renderText(font, 32, 'Level 1', 0xffffffff);
80-
image.composite(levelText, 0.05 * image.width + xpBarBackground.width - levelText.width, 0.65 * image.height - levelText.height);
79+
const levelText = await Image.renderText(font, 32, 'Level 1', {color: 0xffffffff});
80+
image.composite(levelText, {x: 0.05 * image.width + xpBarBackground.width - levelText.width, y: 0.65 * image.height - levelText.height});
8181

82-
const xpKindText = await Image.renderText(font, 32, 'Server XP', 0xffffffff);
83-
image.composite(xpKindText, 0.05 * image.width, 0.65 * image.height - levelText.height);
82+
const xpKindText = await Image.renderText(font, 32, 'Server XP', {color: 0xffffffff});
83+
image.composite(xpKindText, {x: 0.05 * image.width, y: 0.65 * image.height - levelText.height});
8484
}
8585

8686
const badgeBackground = new Image(...Array(2).fill(Math.sqrt(64 ** 2 * 2)));
8787
badgeBackground.fill(0xa0a0a080);
8888
badgeBackground.cropCircle();
8989
for (let i = 0; i < badges.length; i++) {
90-
image.composite(badgeBackground, 0.05 * image.width + 0.9 * image.width / badges.length * i, 0.8 * image.height);
90+
image.composite(badgeBackground, {x: 0.05 * image.width + 0.9 * image.width / badges.length * i, y: 0.8 * image.height});
9191

92-
const badge = await Image.renderSVG(badges[i], 64, Image.SVG_MODE_WIDTH);
92+
const badge = await Image.renderSVG(badges[i], {size: 64, mode: Image.SVG_MODE_WIDTH});
9393
if (i >= 3)
9494
badge.saturation(0);
9595

96-
image.composite(
97-
badge,
98-
0.05 * image.width + 0.9 * image.width / badges.length * i + (badgeBackground.width - badge.width) / 2,
99-
0.8 * image.height + (badgeBackground.height - badge.height) / 2
100-
);
96+
image.composite(badge, {
97+
x: 0.05 * image.width + 0.9 * image.width / badges.length * i + (badgeBackground.width - badge.width) / 2,
98+
y: 0.8 * image.height + (badgeBackground.height - badge.height) / 2
99+
});
101100
}
102101

103102
image.roundCorners(32);
104103

105-
const encoded = await image.encode(1, {creationTime: 0, software: ''});
104+
const encoded = await image.encode({metadata: {creationTime: 0, software: ''}});
106105

107106
if (process.env.OVERWRITE_TEST)
108107
await fs.writeFile('./tests/targets/readme.png', encoded);

0 commit comments

Comments
 (0)