|
| 1 | +--- |
| 2 | +slug: Release of a new version |
| 3 | +title: Release Notes |
| 4 | +date: 2024-01-15 |
| 5 | +authors: [maxim] |
| 6 | +tags: [release] |
| 7 | +--- |
| 8 | + |
| 9 | +We're excited to announce the release of image-js-typescript, a complete rewrite of the popular image-js library. This new version brings modern TypeScript support and a more intuitive API while maintaining the powerful image processing capabilities you love. |
| 10 | + |
| 11 | +## ⚠️ API Changes |
| 12 | + |
| 13 | +### Stricter typing |
| 14 | + |
| 15 | +```js |
| 16 | +// Before |
| 17 | +const pixel = img.getPixel(x, y); // any[] |
| 18 | + |
| 19 | +// After |
| 20 | +const pixel = img.getPixel(x, y); // number[] with proper typing |
| 21 | +``` |
| 22 | + |
| 23 | +### Changed the way images are loaded and created |
| 24 | + |
| 25 | +Static method `load` for reading and writing images has been replaced with dedicated functions `read` and `write`. There are also synchronous versions of these functions.(add more explanation) |
| 26 | + |
| 27 | +```ts |
| 28 | +javascript; // Before |
| 29 | +import { Image } from 'image-js'; |
| 30 | +const img = await Image.load('cat.jpg'); |
| 31 | +``` |
| 32 | + |
| 33 | +```ts |
| 34 | +// After |
| 35 | +import { readSync, read } from 'image-js'; |
| 36 | +const img = readSync('cat.jpg'); |
| 37 | +// or |
| 38 | +const img = await read('cat.jpg'); |
| 39 | +``` |
| 40 | + |
| 41 | +### Distinction between Image and Mask objects |
| 42 | + |
| 43 | +In the new version of ImageJS binary images(masks) becomes a separate class. |
| 44 | + |
| 45 | +```ts |
| 46 | +// Before |
| 47 | +const mask = new Image(10, 10, { kind: 'BINARY' }); |
| 48 | +``` |
| 49 | + |
| 50 | +```ts |
| 51 | +// After |
| 52 | +const mask = new Mask(10, 10); |
| 53 | +``` |
| 54 | + |
| 55 | +In previous versions binary images (masks) had 8 pixels of data stacked in one byte.The new version changes that. Now Masks' data reserves 1 byte per pixel. |
| 56 | +It improves and facilitates data readability and editing. |
| 57 | + |
| 58 | +### New features |
| 59 | + |
| 60 | +- Bicubic interpolation has been added as interpolation option |
| 61 | +- Canny Edge Detector filter has been added |
| 62 | +- `transform` function now accepts 3x3 matrices as well as 2x3 |
| 63 | +- `warpingFourPoints` function has been deprecated and now `getPerspectiveWarp` returns a matrix that can be used in a new `transform()` function. |
| 64 | + |
| 65 | +### Refactored functions |
| 66 | + |
| 67 | +Several methods have been renamed. Some notable changes: |
| 68 | + |
| 69 | +- `paint*` methods(`drawPoligon()`, `paintPolyline()` etc.) are now `draw\*` methods(`drawPolyline()`,`drawPoligon()` etc.). |
| 70 | +- `copy()` → `clone()` |
| 71 | +- `clearBit()` → `setBit()`,`setBitByPoint()`,`setBitByCoord()` |
| 72 | +- `getLocalMaxima` → `getExtrema` |
| 73 | +- `getChannel()`→`extractChannel()` |
| 74 | + |
| 75 | +### Bug fixes |
| 76 | + |
| 77 | +- Fixed perspectiveWarp functioning |
| 78 | + |
| 79 | +### Removed Features |
| 80 | + |
| 81 | +- `countAlphaPixel` was removed. |
| 82 | +- `paintLabels` was removed. |
| 83 | + |
| 84 | +### Configuration Changes |
| 85 | + |
| 86 | +Default parameters: Some filter defaults have changed for better results |
| 87 | +Color space handling: Improved but different color space conversion behavior |
| 88 | + |
| 89 | +## 📚 Resources |
| 90 | + |
| 91 | +[API Documentation](https://image-js.github.io/image-js-typescript/) |
| 92 | +[Examples and Tutorials](https://image-js-docs.pages.dev/) |
| 93 | +[GitHub Repository](https://github.com/image-js/image-js-typescript) |
| 94 | + |
| 95 | +## 🤝 Contributing |
| 96 | + |
| 97 | +We welcome contributions! The new TypeScript codebase makes it easier than ever to contribute. Check out our contributing guide to get started. |
| 98 | + |
| 99 | +## 🙏 Acknowledgments |
| 100 | + |
| 101 | +Special thanks to all contributors who made this release possible and to the community for their feedback and support during the development process. |
| 102 | + |
| 103 | +Ready to upgrade? Check out our migration guide to get started with image-js-typescript today! |
0 commit comments