wasm-image-processor 0.1.0 → 0.2.0
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 -12
- package/package.json +1 -1
- package/wasm_image_processor_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# WASM Image Processor
|
|
2
2
|
> Process images offline in the Browser.
|
|
3
3
|
|
|
4
|
-
**⚠️ Early Development Notice**: This project is in active development. APIs may change
|
|
4
|
+
**⚠️ Early Development Notice**: This project is in active development. APIs may change. Use at your own risk for production applications.
|
|
5
5
|
|
|
6
6
|
A high-performance image processing toolkit built with Rust and WebAssembly. Process images entirely client-side with no server uploads required.
|
|
7
7
|
|
|
@@ -30,16 +30,18 @@ Try the live demo at: [https://stanleymasinde.github.io/wasm-image-processor/](h
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
|
+
```shell
|
|
34
|
+
npm i wasm-image-processor
|
|
35
|
+
```
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
## Building
|
|
35
38
|
|
|
36
39
|
### Prerequisites
|
|
37
40
|
|
|
38
41
|
- [Rust](https://rustup.rs/)
|
|
39
42
|
- [wasm-pack](https://rustwasm.github.io/wasm-pack/)
|
|
40
43
|
|
|
41
|
-
###
|
|
42
|
-
|
|
44
|
+
### Steps
|
|
43
45
|
1. Clone the repository:
|
|
44
46
|
```bash
|
|
45
47
|
git clone https://github.com/yourusername/wasm-image-processor.git
|
|
@@ -73,12 +75,12 @@ Include the WASM module in your web page:
|
|
|
73
75
|
|
|
74
76
|
```html
|
|
75
77
|
<script type="module">
|
|
76
|
-
import init, { resize_square } from "
|
|
78
|
+
import init, { resize_square } from "pwa_image_generator";
|
|
77
79
|
|
|
78
80
|
init().then(() => {
|
|
79
81
|
// WASM module is ready
|
|
80
82
|
const imageData = new Uint8Array(/* your image data */);
|
|
81
|
-
const resizedBytes =
|
|
83
|
+
const resizedBytes = resize_square(Array.from(imageData), 500);
|
|
82
84
|
|
|
83
85
|
// Use resizedBytes as needed
|
|
84
86
|
});
|
|
@@ -87,7 +89,7 @@ Include the WASM module in your web page:
|
|
|
87
89
|
|
|
88
90
|
### API Reference
|
|
89
91
|
|
|
90
|
-
#### `
|
|
92
|
+
#### `resize_square(image_data: Vec<u8>, side: u32) -> Vec<u8>`
|
|
91
93
|
|
|
92
94
|
Resizes an image to a square with the specified side length.
|
|
93
95
|
|
|
@@ -100,7 +102,7 @@ Resizes an image to a square with the specified side length.
|
|
|
100
102
|
|
|
101
103
|
**Example:**
|
|
102
104
|
```javascript
|
|
103
|
-
const resizedBytes =
|
|
105
|
+
const resizedBytes = resize_square(imageBytes, 256);
|
|
104
106
|
const blob = new Blob([new Uint8Array(resizedBytes)], { type: 'image/png' });
|
|
105
107
|
```
|
|
106
108
|
|
|
@@ -117,7 +119,7 @@ wasm-image-processor/
|
|
|
117
119
|
│ └── pwa_image_generator_bg.wasm # Generated WASM binary
|
|
118
120
|
├── pkg/ # wasm-pack output
|
|
119
121
|
├── tests/ # Test files
|
|
120
|
-
├──
|
|
122
|
+
├── prep-demo.sh # Copy the build to the demo folder
|
|
121
123
|
├── Cargo.toml
|
|
122
124
|
└── README.md
|
|
123
125
|
```
|
|
@@ -129,9 +131,6 @@ wasm-image-processor/
|
|
|
129
131
|
```bash
|
|
130
132
|
# Run Rust tests
|
|
131
133
|
cargo test
|
|
132
|
-
|
|
133
|
-
# Test with sample images
|
|
134
|
-
cargo test test_resize_logic --lib
|
|
135
134
|
```
|
|
136
135
|
|
|
137
136
|
### Adding New Features
|
package/package.json
CHANGED
|
Binary file
|