wasm-vips 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/lib/vips-es6.js +215 -215
- package/lib/vips-heif.wasm +0 -0
- package/lib/vips-jxl.wasm +0 -0
- package/lib/vips-node.js +199 -198
- package/lib/vips-node.mjs +199 -197
- package/lib/vips-resvg.wasm +0 -0
- package/lib/vips.d.ts +8 -1
- package/lib/vips.js +215 -215
- package/lib/vips.wasm +0 -0
- package/package.json +1 -1
- package/versions.json +5 -5
package/README.md
CHANGED
|
@@ -120,32 +120,36 @@ const vips = await Vips();
|
|
|
120
120
|
|
|
121
121
|
## Example
|
|
122
122
|
|
|
123
|
-
```
|
|
123
|
+
```ts
|
|
124
124
|
// Load an image from a file
|
|
125
|
-
|
|
125
|
+
using im = vips.Image.newFromFile('owl.jpg');
|
|
126
126
|
|
|
127
127
|
// Put im at position (100, 100) in a 3000 x 3000 pixel image,
|
|
128
128
|
// make the other pixels in the image by mirroring im up / down /
|
|
129
129
|
// left / right, see
|
|
130
130
|
// https://www.libvips.org/API/current/libvips-conversion.html#vips-embed
|
|
131
|
-
|
|
131
|
+
using embed = im.embed(100, 100, 3000, 3000, {
|
|
132
132
|
extend: 'mirror'
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
// Multiply the green (middle) band by 2, leave the other two alone
|
|
136
|
-
|
|
136
|
+
using multiply = embed.multiply([1, 2, 1]);
|
|
137
137
|
|
|
138
138
|
// Make an image from an array constant, convolve with it
|
|
139
|
-
|
|
139
|
+
using mask = vips.Image.newFromArray([
|
|
140
140
|
[-1, -1, -1],
|
|
141
141
|
[-1, 16, -1],
|
|
142
142
|
[-1, -1, -1]
|
|
143
143
|
], 8.0);
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
using convolve = multiply.conv(mask, {
|
|
146
146
|
precision: 'integer'
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
// Finally, write the result to a buffer
|
|
150
|
-
const outBuffer =
|
|
150
|
+
const outBuffer = convolve.writeToBuffer('.jpg');
|
|
151
151
|
```
|
|
152
|
+
<sup>If not transpiling, this requires support for the [`using`](
|
|
153
|
+
https://caniuse.com/mdn-javascript_statements_using) keyword. On Node.js,
|
|
154
|
+
you can enable it with the `--js-explicit-resource-management` CLI flag.
|
|
155
|
+
</sup>
|