You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0767ec8
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
-**`image.quantize({ colors, palette, dither, ditherStrength })`**: reduces the image to a palette, in place: `image.quantize({ colors: 16 })` for the 16 colors that best represent it, or a fixed one: `image.quantize({ palette: [0x0f380fff, 0x306230ff, 0x8bac0fff, 0x9bbc0fff] })` for a Game Boy look. `dither: 'floyd-steinberg'` (or `'atkinson'`, or `'ordered'` for a regular pattern) makes gradients look smooth with few colors. Transparent pixels keep their color and don't count towards the palette.
8
8
-**`Image.renderSVG(svg, { images })`**: images for the `<image>` elements by their `href`, without data URIs: `Image.renderSVG('<svg ...><image href="logo.png" .../></svg>', { images: { 'logo.png': bytes } })`. The values are encoded images or `Image`s; they are decoded only when the SVG uses them. Nothing is read from files or URLs.
9
9
-**`image.colorMatrix(matrix)`**: mixes the colors of every pixel with a color matrix, like SVG's `feColorMatrix`: greyscale, sepia, tints, swapped channels, color blindness simulation or any mix of them in one pass. Twenty values (four rows of `[red, green, blue, alpha, offset]`, 0 to 1) or nine for just the colors: `image.colorMatrix([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0])` swaps red and blue.
10
+
-**`image.transform(matrix, { origin, expand, mode })`**: moves every point of the image with an affine transform in one resampling: rotation, scaling, skew, flips and shifts in any mix and around any point. The six values are SVG's `matrix(a b c d e f)`: `image.transform([1, 0, -0.3, 1, 0, 0])` slants an image like italics. The image grows to hold the result unless `expand: false`, and `mode` is `'nearest-neighbor'`, `'bilinear'` (default) or `'bicubic'`.
if(!TRANSFORM_MODES.includes(mode))thrownewTypeError(`transform mode must be one of ${TRANSFORM_MODES.map(name=>`'${name}'`).join(', ')}, not ${String(mode)}`);
// the size rounds, the transformed image is centered on the canvas (a turned image is a bit off a pixel size)
2224
+
outWidth=Math.max(1,Math.round(maxX-minX));
2225
+
outHeight=Math.max(1,Math.round(maxY-minY));
2226
+
left=minX-(outWidth-(maxX-minX))/2;
2227
+
top=minY-(outHeight-(maxY-minY))/2;
2228
+
// frames only grow as far up and left as their offset allows
2229
+
constroom=this.__room__();
2230
+
if(left<-room.left){
2231
+
left=-room.left;
2232
+
outWidth=Math.max(1,Math.round(maxX-left));
2233
+
}
2234
+
if(top<-room.top){
2235
+
top=-room.top;
2236
+
outHeight=Math.max(1,Math.round(maxY-top));
2237
+
}
2238
+
if(outWidth*outHeight>MAX_PIXELS)thrownewRangeError(`The transformed image would have ${outWidth}x${outHeight} pixels, more than the ${MAX_PIXELS} allowed`);
0 commit comments