@robinpath/image
0.1.1Node.jsPublicImage processing: resize, crop, convert, watermark, and metadata
Image
Image processing with Sharp: resize, crop, convert, rotate, flip, grayscale, blur, composite/watermark, and thumbnails
Package: @robinpath/image | Category: Other | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the image module when you need to:
- Resize an image -- Use
image.resizeto perform this operation - Crop a region from an image -- Use
image.cropto perform this operation - Convert image format (png, jpeg, webp, avif) -- Use
image.convertto perform this operation - Get image metadata -- Use
image.metadatato perform this operation - Rotate an image -- Use
image.rotateto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
resize | Resize an image | {path, width, height} |
crop | Crop a region from an image | {path} |
convert | Convert image format (png, jpeg, webp, avif) | {path, format} |
metadata | Get image metadata | {width, height, format, channels, size, hasAlpha} |
rotate | Rotate an image | {path, angle} |
flip | Flip an image vertically or horizontally | {path} |
grayscale | Convert to grayscale | {path} |
blur | Apply Gaussian blur | {path} |
composite | Overlay one image on top of another (watermark) | {path} |
thumbnail | Generate a square thumbnail | {path, size} |
Functions
resize
Resize an image
Module: image | Returns: object -- {path, width, height}
image.resize "./photo.jpg" "./thumb.jpg" {"width": 300, "height": 200}
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
options | object | Yes | {width, height, fit} |
crop
Crop a region from an image
Module: image | Returns: object -- {path}
image.crop "./photo.jpg" "./cropped.jpg" {"left": 10, "top": 10, "width": 200, "height": 200}
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
options | object | Yes | {left, top, width, height} |
convert
Convert image format (png, jpeg, webp, avif)
Module: image | Returns: object -- {path, format}
image.convert "./photo.png" "./photo.webp" "webp" 85
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
format | string | Yes | Target format |
quality | number | No | Quality 1-100 (optional) |
metadata
Get image metadata
Module: image | Returns: object -- {width, height, format, channels, size, hasAlpha}
image.metadata "./photo.jpg"
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
rotate
Rotate an image
Module: image | Returns: object -- {path, angle}
image.rotate "./photo.jpg" "./rotated.jpg" 90
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
angle | number | Yes | Rotation angle in degrees |
flip
Flip an image vertically or horizontally
Module: image | Returns: object -- {path}
image.flip "./photo.jpg" "./flipped.jpg" "horizontal"
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
direction | string | No | 'vertical' or 'horizontal' |
grayscale
Convert to grayscale
Module: image | Returns: object -- {path}
image.grayscale "./photo.jpg" "./bw.jpg"
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
blur
Apply Gaussian blur
Module: image | Returns: object -- {path}
image.blur "./photo.jpg" "./blurred.jpg" 5
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
sigma | number | No | Blur sigma (default 3) |
composite
Overlay one image on top of another (watermark)
Module: image | Returns: object -- {path}
image.composite "./photo.jpg" "./watermark.png" "./result.jpg" {"gravity": "southeast"}
| Parameter | Type | Required | Description |
|---|---|---|---|
base | string | Yes | Base image path |
overlay | string | Yes | Overlay image path |
output | string | Yes | Output path |
options | object | No | {top, left, gravity} |
thumbnail
Generate a square thumbnail
Module: image | Returns: object -- {path, size}
image.thumbnail "./photo.jpg" "./thumb.jpg" 150
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Input path |
output | string | Yes | Output path |
size | number | No | Size in pixels (default 200) |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Resize and validate result"
do
set $result as image.resize "./photo.jpg" "./thumb.jpg" {"width": 300, "height": 200}
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step Image workflow
Chain multiple image operations together.
@desc "Resize, crop, and more"
do
set $r_resize as image.resize "./photo.jpg" "./thumb.jpg" {"width": 300, "height": 200}
set $r_crop as image.crop "./photo.jpg" "./cropped.jpg" {"left": 10, "top": 10, "width": 200, "height": 200}
set $r_convert as image.convert "./photo.png" "./photo.webp" "webp" 85
print "All operations complete"
enddo
2. Safe resize with validation
Check results before proceeding.
@desc "Resize and validate result"
do
set $result as image.resize "./photo.jpg" "./thumb.jpg" {"width": 300, "height": 200}
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/image
