@karbonjs/utils 0.3.1 → 0.3.3
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 +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,32 @@ getCookie('theme') // "dark"
|
|
|
75
75
|
deleteCookie('theme')
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
## Image Resizer Helper
|
|
79
|
+
|
|
80
|
+
URL builder for the [Karbon ImgResizer](https://crates.io/crates/karbon-framework) service.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { img } from '@karbonjs/utils'
|
|
84
|
+
|
|
85
|
+
// Basic resize
|
|
86
|
+
img('/files/uploads/photo.jpg', { w: 320, h: 180 })
|
|
87
|
+
// → "/files/r/320x180/uploads/photo.jpg"
|
|
88
|
+
|
|
89
|
+
// Width only (auto height)
|
|
90
|
+
img('/files/uploads/photo.jpg', { w: 640 })
|
|
91
|
+
// → "/files/r/640x0/uploads/photo.jpg"
|
|
92
|
+
|
|
93
|
+
// Cover crop + WebP + quality
|
|
94
|
+
img('/files/uploads/photo.jpg', { w: 320, h: 180, mode: 'cover', format: 'webp', quality: 85 })
|
|
95
|
+
// → "/files/r/320x180_cover_q85.webp/uploads/photo.jpg"
|
|
96
|
+
|
|
97
|
+
// Grayscale + blur
|
|
98
|
+
img('/files/uploads/photo.jpg', { w: 400, h: 400, grayscale: true, blur: 2 })
|
|
99
|
+
// → "/files/r/400x400_gray_blur2/uploads/photo.jpg"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Options: `w`, `h`, `mode` (fit/cover/stretch), `format` (webp/jpeg/png), `quality` (1-100), `grayscale`, `blur`, `anchor`.
|
|
103
|
+
|
|
78
104
|
## License
|
|
79
105
|
|
|
80
106
|
MIT
|