wasm-vips 0.0.12 → 0.0.14

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 CHANGED
@@ -120,32 +120,36 @@ const vips = await Vips();
120
120
 
121
121
  ## Example
122
122
 
123
- ```js
123
+ ```ts
124
124
  // Load an image from a file
125
- let im = vips.Image.newFromFile('owl.jpg');
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
- im = im.embed(100, 100, 3000, 3000, {
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
- im = im.multiply([1, 2, 1]);
136
+ using multiply = embed.multiply([1, 2, 1]);
137
137
 
138
138
  // Make an image from an array constant, convolve with it
139
- const mask = vips.Image.newFromArray([
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
- im = im.conv(mask, {
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 = im.writeToBuffer('.jpg');
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>