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
Copy file name to clipboardExpand all lines: blog/release.md
+45-8Lines changed: 45 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,9 @@ This eliminates runtime type errors and provides better IntelliSense, autocomple
26
26
27
27
## ⚠️ Breaking changes
28
28
29
-
### Loading and saving images
29
+
### Images
30
+
31
+
#### Loading and saving
30
32
31
33
`load()` and `save()` have been replaced with dedicated functions `read()` and `write()`.
32
34
@@ -54,7 +56,7 @@ writeSync('newCat.jpg', img);
54
56
55
57
The new approach allows for better TypeScript inference, smaller bundle sizes through tree-shaking, and clearer API design where I/O operations are separate from image manipulation.
56
58
57
-
### Creating images
59
+
####Creating
58
60
59
61
When creating a new image, unlike before, image's width and height must be specified.
60
62
@@ -69,6 +71,20 @@ const image2 = new Image(10, 10);
69
71
70
72
This change makes the Image constructor more explicit by requiring you to specify the dimensions upfront, preventing potential errors from working with uninitialized or undefined-sized images
71
73
74
+
#### Image position
75
+
76
+
Images now include an `origin` property that tracks their position relative to their parent image. When you crop an image, the cropped section remembers where it came from in the original image.
Binary images are now handled by a dedicated `Mask` class instead of Image with `kind: 'BINARY'`.
@@ -87,6 +103,27 @@ const mask = new Mask(10, 10);
87
103
88
104
The new `Mask` class uses 1 byte per pixel (vs 8 pixels per byte), trading ~8x memory usage for significantly faster bit operations and simpler data manipulation.
89
105
106
+
### Points
107
+
108
+
Coordinates are now represented using `Point` objects instead of arrays. This change affects methods that require coordinate input like cropping, drawing, and pixel manipulation.
109
+
110
+
```ts
111
+
// Before
112
+
const croppedImage =img.crop({
113
+
origin: [10, 10],
114
+
width: 10,
115
+
height: 10,
116
+
});
117
+
// After
118
+
const croppedImage =img.crop({
119
+
origin: { column: 10, row: 10 },
120
+
width: 10,
121
+
height: 10,
122
+
});
123
+
```
124
+
125
+
It is a more explicit and self-documenting code and it also eliminates confusion about array order (column vs row).
126
+
90
127
### Sobel and Scharr filters
91
128
92
129
[Sobel](https://en.wikipedia.org/wiki/Sobel_operator), [Scharr](https://en.wikipedia.org/wiki/Sobel_operator#Alternative_operators) filters are now combined into a single `derivative()` method.
@@ -143,12 +180,12 @@ The following deprecated features have been removed:
143
180
-`countAlphaPixel()` - Use custom pixel counting with `getPixel()`
144
181
-`paintLabels()` - Feature was removed due to dependency issues. We plan to add it back in the future updates.
145
182
-`warpingFourPoints()` - Use `getPerspectiveWarp()` + `transform()`.
146
-
- 32-bit color depth has been currently deprecated. We plan to add it back in the future updates as well.
147
-
-`CMYK` and `HSL` color models have been deprecated. We plan to add it in the future updates.
148
-
-`insert()` has been deprecated. We plan to add it in the future updates.
149
-
-`abs()` has been deprecated. Currently 32-bit images are not supported.
150
-
-`paintMasks()` has been deprecated. Use `paintMask()`+ `for` loop.
151
-
-`mergeRois()` has been deprecated. We plan to add it in the future updates.
183
+
- 32-bit color depth has been currently removed. We plan to add it back in the future updates as well.
184
+
-`CMYK` and `HSL` color models have been removed.
185
+
-`insert()` has been removed.
186
+
-`abs()` has been removed.
187
+
-`paintMasks()` has been removed. Use `paintMask()`+ `for` loop.
0 commit comments