apexify.js 4.9.30 → 5.0.1
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/CHANGELOG.md +137 -0
- package/README.md +119 -4
- package/apex-banner.png +0 -0
- package/dist/cjs/Canvas/ApexPainter.d.ts +158 -145
- package/dist/cjs/Canvas/ApexPainter.d.ts.map +1 -1
- package/dist/cjs/Canvas/ApexPainter.js +1443 -418
- package/dist/cjs/Canvas/ApexPainter.js.map +1 -1
- package/dist/cjs/Canvas/utils/Charts/charts.d.ts +7 -2
- package/dist/cjs/Canvas/utils/Charts/charts.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/Charts/charts.js +3 -1
- package/dist/cjs/Canvas/utils/Charts/charts.js.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts +75 -0
- package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/Custom/advancedLines.js +263 -0
- package/dist/cjs/Canvas/utils/Custom/advancedLines.js.map +1 -0
- package/dist/cjs/Canvas/utils/Custom/customLines.d.ts +2 -1
- package/dist/cjs/Canvas/utils/Custom/customLines.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/customLines.js +73 -6
- package/dist/cjs/Canvas/utils/Custom/customLines.js.map +1 -1
- package/dist/cjs/Canvas/utils/General/batchOperations.d.ts +17 -0
- package/dist/cjs/Canvas/utils/General/batchOperations.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/General/batchOperations.js +88 -0
- package/dist/cjs/Canvas/utils/General/batchOperations.js.map +1 -0
- package/dist/cjs/Canvas/utils/General/general functions.d.ts +25 -3
- package/dist/cjs/Canvas/utils/General/general functions.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/General/general functions.js +37 -9
- package/dist/cjs/Canvas/utils/General/general functions.js.map +1 -1
- package/dist/cjs/Canvas/utils/General/imageCompression.d.ts +19 -0
- package/dist/cjs/Canvas/utils/General/imageCompression.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/General/imageCompression.js +262 -0
- package/dist/cjs/Canvas/utils/General/imageCompression.js.map +1 -0
- package/dist/cjs/Canvas/utils/General/imageStitching.d.ts +20 -0
- package/dist/cjs/Canvas/utils/General/imageStitching.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/General/imageStitching.js +227 -0
- package/dist/cjs/Canvas/utils/General/imageStitching.js.map +1 -0
- package/dist/cjs/Canvas/utils/Image/imageEffects.d.ts +37 -0
- package/dist/cjs/Canvas/utils/Image/imageEffects.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/Image/imageEffects.js +128 -0
- package/dist/cjs/Canvas/utils/Image/imageEffects.js.map +1 -0
- package/dist/cjs/Canvas/utils/Image/imageMasking.d.ts +67 -0
- package/dist/cjs/Canvas/utils/Image/imageMasking.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/Image/imageMasking.js +276 -0
- package/dist/cjs/Canvas/utils/Image/imageMasking.js.map +1 -0
- package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.js +16 -8
- package/dist/cjs/Canvas/utils/Patterns/enhancedPatternRenderer.js.map +1 -1
- package/dist/cjs/Canvas/utils/Texts/textPathRenderer.d.ts +17 -0
- package/dist/cjs/Canvas/utils/Texts/textPathRenderer.d.ts.map +1 -0
- package/dist/cjs/Canvas/utils/Texts/textPathRenderer.js +233 -0
- package/dist/cjs/Canvas/utils/Texts/textPathRenderer.js.map +1 -0
- package/dist/cjs/Canvas/utils/types.d.ts +153 -0
- package/dist/cjs/Canvas/utils/types.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/types.js.map +1 -1
- package/dist/cjs/Canvas/utils/utils.d.ts +9 -2
- package/dist/cjs/Canvas/utils/utils.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/utils.js +32 -1
- package/dist/cjs/Canvas/utils/utils.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/Canvas/ApexPainter.d.ts +158 -145
- package/dist/esm/Canvas/ApexPainter.d.ts.map +1 -1
- package/dist/esm/Canvas/ApexPainter.js +1443 -418
- package/dist/esm/Canvas/ApexPainter.js.map +1 -1
- package/dist/esm/Canvas/utils/Charts/charts.d.ts +7 -2
- package/dist/esm/Canvas/utils/Charts/charts.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/Charts/charts.js +3 -1
- package/dist/esm/Canvas/utils/Charts/charts.js.map +1 -1
- package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts +75 -0
- package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/Custom/advancedLines.js +263 -0
- package/dist/esm/Canvas/utils/Custom/advancedLines.js.map +1 -0
- package/dist/esm/Canvas/utils/Custom/customLines.d.ts +2 -1
- package/dist/esm/Canvas/utils/Custom/customLines.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/Custom/customLines.js +73 -6
- package/dist/esm/Canvas/utils/Custom/customLines.js.map +1 -1
- package/dist/esm/Canvas/utils/General/batchOperations.d.ts +17 -0
- package/dist/esm/Canvas/utils/General/batchOperations.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/General/batchOperations.js +88 -0
- package/dist/esm/Canvas/utils/General/batchOperations.js.map +1 -0
- package/dist/esm/Canvas/utils/General/general functions.d.ts +25 -3
- package/dist/esm/Canvas/utils/General/general functions.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/General/general functions.js +37 -9
- package/dist/esm/Canvas/utils/General/general functions.js.map +1 -1
- package/dist/esm/Canvas/utils/General/imageCompression.d.ts +19 -0
- package/dist/esm/Canvas/utils/General/imageCompression.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/General/imageCompression.js +262 -0
- package/dist/esm/Canvas/utils/General/imageCompression.js.map +1 -0
- package/dist/esm/Canvas/utils/General/imageStitching.d.ts +20 -0
- package/dist/esm/Canvas/utils/General/imageStitching.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/General/imageStitching.js +227 -0
- package/dist/esm/Canvas/utils/General/imageStitching.js.map +1 -0
- package/dist/esm/Canvas/utils/Image/imageEffects.d.ts +37 -0
- package/dist/esm/Canvas/utils/Image/imageEffects.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/Image/imageEffects.js +128 -0
- package/dist/esm/Canvas/utils/Image/imageEffects.js.map +1 -0
- package/dist/esm/Canvas/utils/Image/imageMasking.d.ts +67 -0
- package/dist/esm/Canvas/utils/Image/imageMasking.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/Image/imageMasking.js +276 -0
- package/dist/esm/Canvas/utils/Image/imageMasking.js.map +1 -0
- package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.js +16 -8
- package/dist/esm/Canvas/utils/Patterns/enhancedPatternRenderer.js.map +1 -1
- package/dist/esm/Canvas/utils/Texts/textPathRenderer.d.ts +17 -0
- package/dist/esm/Canvas/utils/Texts/textPathRenderer.d.ts.map +1 -0
- package/dist/esm/Canvas/utils/Texts/textPathRenderer.js +233 -0
- package/dist/esm/Canvas/utils/Texts/textPathRenderer.js.map +1 -0
- package/dist/esm/Canvas/utils/types.d.ts +153 -0
- package/dist/esm/Canvas/utils/types.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/types.js.map +1 -1
- package/dist/esm/Canvas/utils/utils.d.ts +9 -2
- package/dist/esm/Canvas/utils/utils.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/utils.js +32 -1
- package/dist/esm/Canvas/utils/utils.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/Canvas/ApexPainter.ts +1327 -266
- package/lib/Canvas/utils/Charts/charts.ts +16 -7
- package/lib/Canvas/utils/Custom/advancedLines.ts +335 -0
- package/lib/Canvas/utils/Custom/customLines.ts +84 -9
- package/lib/Canvas/utils/General/batchOperations.ts +103 -0
- package/lib/Canvas/utils/General/general functions.ts +85 -41
- package/lib/Canvas/utils/General/imageCompression.ts +316 -0
- package/lib/Canvas/utils/General/imageStitching.ts +252 -0
- package/lib/Canvas/utils/Image/imageEffects.ts +175 -0
- package/lib/Canvas/utils/Image/imageMasking.ts +335 -0
- package/lib/Canvas/utils/Patterns/enhancedPatternRenderer.ts +455 -444
- package/lib/Canvas/utils/Texts/textPathRenderer.ts +320 -0
- package/lib/Canvas/utils/types.ts +156 -0
- package/lib/Canvas/utils/utils.ts +52 -2
- package/package.json +75 -35
- package/types/imgur.d.ts +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Apexify.js will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [5.0.0] - 2024-12-20
|
|
9
|
+
|
|
10
|
+
### 🎉 Major Feature Release - Advanced Image & Canvas Features
|
|
11
|
+
|
|
12
|
+
#### ✨ Added
|
|
13
|
+
|
|
14
|
+
##### Background Enhancements
|
|
15
|
+
- **Background Image Filters**: Apply filters directly to background images via `customBg.filters`
|
|
16
|
+
- **Background Image Opacity**: Control background image transparency with `customBg.opacity`
|
|
17
|
+
- **Video Backgrounds**: Support for video backgrounds with frame extraction via `videoBg` option
|
|
18
|
+
- Extract specific frames from videos
|
|
19
|
+
- Loop and autoplay support
|
|
20
|
+
- Opacity control for video backgrounds
|
|
21
|
+
|
|
22
|
+
##### Image Processing Enhancements
|
|
23
|
+
- **Image Masking**: Apply masks to images with multiple modes (`alpha`, `luminance`, `inverse`)
|
|
24
|
+
- **Custom Clip Paths**: Define custom polygon clipping paths for images
|
|
25
|
+
- **Image Distortion**:
|
|
26
|
+
- Perspective distortion with 4-point control
|
|
27
|
+
- Bulge/pinch effects with intensity control
|
|
28
|
+
- Mesh warping with customizable grid control points
|
|
29
|
+
- **Effects Stack**: Professional image effects
|
|
30
|
+
- Vignette effect with intensity and size control
|
|
31
|
+
- Lens flare with position and intensity
|
|
32
|
+
- Chromatic aberration effect
|
|
33
|
+
- Film grain effect
|
|
34
|
+
- **Enhanced Filters**:
|
|
35
|
+
- `filterIntensity` - Global intensity multiplier for all filters
|
|
36
|
+
- `filterOrder` - Control when filters are applied (`pre` or `post` transformation)
|
|
37
|
+
|
|
38
|
+
##### Text Enhancements
|
|
39
|
+
- **Text on Paths**: Render text along curves and paths
|
|
40
|
+
- Support for line, arc, bezier, and quadratic curve paths
|
|
41
|
+
- Offset control for text distance from path
|
|
42
|
+
- Automatic text distribution along path
|
|
43
|
+
|
|
44
|
+
##### Custom Lines Enhancements
|
|
45
|
+
- **Advanced Path Options**:
|
|
46
|
+
- Smooth path interpolation with tension control
|
|
47
|
+
- Bezier curve paths
|
|
48
|
+
- Catmull-Rom spline paths
|
|
49
|
+
- Closed path support
|
|
50
|
+
- **Arrow Markers**:
|
|
51
|
+
- Start and end arrows on lines
|
|
52
|
+
- Customizable arrow size and style (filled/outline)
|
|
53
|
+
- Color control for arrows
|
|
54
|
+
- **Path Markers**:
|
|
55
|
+
- Add markers at any position along a path (0-1)
|
|
56
|
+
- Multiple marker shapes: circle, square, diamond, arrow
|
|
57
|
+
- Customizable marker size and color
|
|
58
|
+
- **Line Patterns**:
|
|
59
|
+
- Built-in patterns: dots, dashes, custom segments
|
|
60
|
+
- Pattern offset control
|
|
61
|
+
- **Line Textures**: Apply texture images to lines
|
|
62
|
+
|
|
63
|
+
##### New Utility Methods
|
|
64
|
+
- **Batch Operations**: `batch()` - Process multiple operations in parallel
|
|
65
|
+
- **Chain Operations**: `chain()` - Chain operations sequentially
|
|
66
|
+
- **Image Stitching**: `stitchImages()` - Stitch multiple images together
|
|
67
|
+
- Horizontal, vertical, and grid layouts
|
|
68
|
+
- Overlap and blend support
|
|
69
|
+
- Spacing control
|
|
70
|
+
- **Collage Maker**: `createCollage()` - Create image collages
|
|
71
|
+
- Grid, masonry, carousel, and custom layouts
|
|
72
|
+
- Automatic spacing and alignment
|
|
73
|
+
- Background and border radius support
|
|
74
|
+
- **Image Compression**: `compress()` - Compress images with quality control
|
|
75
|
+
- Support for JPEG, WebP, and AVIF formats
|
|
76
|
+
- Progressive JPEG support
|
|
77
|
+
- Max width/height constraints
|
|
78
|
+
- **Color Palette Extraction**: `extractPalette()` - Extract color palettes from images
|
|
79
|
+
- Multiple algorithms: k-means, median-cut, octree
|
|
80
|
+
- Customizable color count
|
|
81
|
+
- Multiple output formats: hex, rgb, hsl
|
|
82
|
+
- **Advanced Save Method**: `save()` - Save buffers to local files with extensive customization
|
|
83
|
+
- Multiple file formats: PNG, JPEG, WebP, AVIF, GIF
|
|
84
|
+
- Smart naming patterns: timestamp, counter, or custom
|
|
85
|
+
- Auto-create directories
|
|
86
|
+
- Quality control for JPEG/WebP
|
|
87
|
+
- Prefix/suffix support
|
|
88
|
+
- Overwrite protection with auto-renaming
|
|
89
|
+
- Batch saving with `saveMultiple()`
|
|
90
|
+
- Counter management with `resetSaveCounter()`
|
|
91
|
+
|
|
92
|
+
#### 🔧 Technical Improvements
|
|
93
|
+
- Added comprehensive TypeScript type definitions for all new features
|
|
94
|
+
- Created utility modules for better code organization:
|
|
95
|
+
- `imageMasking.ts` - Image masking and distortion utilities
|
|
96
|
+
- `imageEffects.ts` - Image effects utilities
|
|
97
|
+
- `textPathRenderer.ts` - Text path rendering utilities
|
|
98
|
+
- `advancedLines.ts` - Advanced line drawing utilities
|
|
99
|
+
- `batchOperations.ts` - Batch and chain operation utilities
|
|
100
|
+
- `imageStitching.ts` - Image stitching and collage utilities
|
|
101
|
+
- `imageCompression.ts` - Image compression and palette extraction utilities
|
|
102
|
+
- Enhanced error handling and validation
|
|
103
|
+
- Improved type safety across all new features
|
|
104
|
+
|
|
105
|
+
#### 📚 Documentation
|
|
106
|
+
- Updated README with new features
|
|
107
|
+
- Added comprehensive examples for all new features
|
|
108
|
+
- Enhanced API documentation
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## [4.9.28] - Previous Release
|
|
113
|
+
|
|
114
|
+
### Features
|
|
115
|
+
- Enhanced text renderer with decorations
|
|
116
|
+
- Professional pattern system
|
|
117
|
+
- Advanced gradient support
|
|
118
|
+
- Comprehensive shape drawing
|
|
119
|
+
- Chart generation capabilities
|
|
120
|
+
- GIF creation support
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## [4.9.0] - Initial Major Release
|
|
125
|
+
|
|
126
|
+
### Features
|
|
127
|
+
- Core canvas creation
|
|
128
|
+
- Image and shape drawing
|
|
129
|
+
- Text rendering
|
|
130
|
+
- Basic filters and effects
|
|
131
|
+
- Format conversion
|
|
132
|
+
- Background removal
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
For a complete list of changes, please refer to the [GitHub repository](https://github.com/zenith-79/apexify.js).
|
|
137
|
+
|
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
**The Ultimate TypeScript Canvas Library for Node.js**
|
|
8
8
|
|
|
9
|
-
[](https://badge.fury.io/js/apexify)
|
|
9
|
+
[](https://badge.fury.io/js/apexify.js)
|
|
10
|
+
[](https://www.npmjs.com/package/apexify.js)
|
|
10
11
|
[](https://www.typescriptlang.org/)
|
|
11
12
|
[](https://nodejs.org/)
|
|
12
13
|
[](LICENSE)
|
|
@@ -19,13 +20,22 @@
|
|
|
19
20
|
|
|
20
21
|
### 🖼️ **Advanced Image Processing**
|
|
21
22
|
- **Professional Filters**: 22+ filters including blur, sharpen, vintage, cinematic effects
|
|
23
|
+
- **Image Masking**: Apply masks with alpha, luminance, or inverse modes
|
|
24
|
+
- **Image Distortion**: Perspective, bulge, pinch, and mesh warping effects
|
|
25
|
+
- **Effects Stack**: Vignette, lens flare, chromatic aberration, film grain
|
|
22
26
|
- **Shape Drawing**: 8+ shapes (rectangle, circle, heart, star, polygon, etc.)
|
|
23
27
|
- **Gradient Support**: Linear and radial gradients for fills and strokes
|
|
24
28
|
- **Shadow & Stroke Effects**: Customizable shadows and strokes for all shapes
|
|
25
29
|
- **Rotation & Positioning**: Full control over image placement and rotation
|
|
30
|
+
- **Image Stitching**: Combine multiple images into panoramas or grids
|
|
31
|
+
- **Collage Maker**: Create beautiful collages with multiple layout options
|
|
32
|
+
- **Image Compression**: Optimize images with quality control (JPEG, WebP, AVIF)
|
|
33
|
+
- **Color Palette Extraction**: Extract color palettes using multiple algorithms
|
|
26
34
|
|
|
27
35
|
### 🎨 **Rich Background System**
|
|
28
36
|
- **Multiple Background Types**: Solid colors, gradients, custom images
|
|
37
|
+
- **Video Backgrounds**: Extract frames from videos for dynamic backgrounds
|
|
38
|
+
- **Background Filters**: Apply filters directly to background images
|
|
29
39
|
- **Pattern Overlays**: 12+ built-in patterns (grid, dots, stripes, hexagons, etc.)
|
|
30
40
|
- **Custom Patterns**: Use your own images as repeating patterns
|
|
31
41
|
- **Blend Modes**: 11+ blend modes for professional compositing
|
|
@@ -33,18 +43,29 @@
|
|
|
33
43
|
|
|
34
44
|
### 📝 **Enhanced Text Rendering**
|
|
35
45
|
- **Font Management**: Custom fonts, sizes, families, and styles
|
|
46
|
+
- **Text on Paths**: Render text along curves (line, arc, bezier, quadratic)
|
|
36
47
|
- **Text Decorations**: Bold, italic, underline, overline, strikethrough, highlight
|
|
37
48
|
- **Advanced Effects**: Glow, shadow, stroke with gradient support
|
|
38
49
|
- **Spacing Control**: Letter spacing, word spacing, line height
|
|
39
50
|
- **Text Wrapping**: Automatic text wrapping with size constraints
|
|
40
51
|
- **Rotation**: Full 360° text rotation support
|
|
41
52
|
|
|
53
|
+
### 🎯 **Advanced Custom Lines**
|
|
54
|
+
- **Smooth Paths**: Bezier, Catmull-Rom, and smooth interpolation
|
|
55
|
+
- **Arrow Markers**: Customizable start/end arrows with multiple styles
|
|
56
|
+
- **Path Markers**: Add markers at any position along paths
|
|
57
|
+
- **Line Patterns**: Dots, dashes, and custom pattern segments
|
|
58
|
+
- **Line Textures**: Apply texture images to lines
|
|
59
|
+
|
|
42
60
|
### 🔧 **Professional Tools**
|
|
43
61
|
- **Chart Generation**: Bar charts, pie charts, line charts
|
|
44
62
|
- **GIF Creation**: Animated GIFs from image sequences
|
|
45
|
-
- **Format Conversion**: Convert between PNG, JPEG, WebP, and more
|
|
63
|
+
- **Format Conversion**: Convert between PNG, JPEG, WebP, AVIF, and more
|
|
46
64
|
- **Image Manipulation**: Crop, resize, background removal
|
|
47
65
|
- **Color Detection**: Extract and analyze colors from images
|
|
66
|
+
- **Batch Operations**: Process multiple operations in parallel
|
|
67
|
+
- **Chain Operations**: Chain operations sequentially for complex workflows
|
|
68
|
+
- **Advanced File Saving**: Save buffers to local files with smart naming, format conversion, and batch support
|
|
48
69
|
|
|
49
70
|
---
|
|
50
71
|
|
|
@@ -149,10 +170,64 @@ const textImage = await painter.createText({
|
|
|
149
170
|
}
|
|
150
171
|
}, heartImage);
|
|
151
172
|
|
|
152
|
-
// Save the result
|
|
153
|
-
|
|
173
|
+
// Save the result using the advanced save method
|
|
174
|
+
const saveResult = await painter.save(textImage, {
|
|
175
|
+
directory: './output',
|
|
176
|
+
filename: 'beautiful-artwork',
|
|
177
|
+
format: 'png'
|
|
178
|
+
});
|
|
179
|
+
console.log(`Saved to: ${saveResult.path} (${saveResult.size} bytes)`);
|
|
180
|
+
|
|
181
|
+
// Or use the simple approach (auto-generated filename)
|
|
182
|
+
const autoSave = await painter.save(textImage);
|
|
183
|
+
// Saves to: ./ApexPainter_output/20241220_143025_123.png
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 💾 **Advanced Save Method**
|
|
187
|
+
|
|
188
|
+
The `save()` method provides powerful file saving capabilities with extensive customization:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Simple save with auto-generated timestamp name
|
|
192
|
+
const canvas = await painter.createCanvas({ width: 800, height: 600 });
|
|
193
|
+
const result = await painter.save(canvas.buffer);
|
|
194
|
+
// Saves to: ./ApexPainter_output/20241220_143025_123.png
|
|
195
|
+
|
|
196
|
+
// Custom filename and directory
|
|
197
|
+
await painter.save(canvas.buffer, {
|
|
198
|
+
directory: './my-images',
|
|
199
|
+
filename: 'my-canvas',
|
|
200
|
+
format: 'jpg',
|
|
201
|
+
quality: 95
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Save with counter naming
|
|
205
|
+
await painter.save(canvas.buffer, {
|
|
206
|
+
naming: 'counter',
|
|
207
|
+
prefix: 'image-',
|
|
208
|
+
counterStart: 1
|
|
209
|
+
});
|
|
210
|
+
// Saves to: ./ApexPainter_output/image-1.png, image-2.png, etc.
|
|
211
|
+
|
|
212
|
+
// Save multiple buffers in batch
|
|
213
|
+
const buffers = [canvas1.buffer, canvas2.buffer, canvas3.buffer];
|
|
214
|
+
const results = await painter.saveMultiple(buffers, {
|
|
215
|
+
prefix: 'batch-',
|
|
216
|
+
naming: 'counter'
|
|
217
|
+
});
|
|
218
|
+
// Saves: batch-1.png, batch-2.png, batch-3.png
|
|
154
219
|
```
|
|
155
220
|
|
|
221
|
+
**Save Options:**
|
|
222
|
+
- `directory` - Output directory (default: `./ApexPainter_output`)
|
|
223
|
+
- `filename` - Custom filename (auto-generated if not provided)
|
|
224
|
+
- `format` - File format: `png`, `jpg`, `jpeg`, `webp`, `avif`, `gif` (default: `png`)
|
|
225
|
+
- `quality` - Quality for JPEG/WebP (0-100, default: 90)
|
|
226
|
+
- `naming` - Naming pattern: `timestamp`, `counter`, or `custom` (default: `timestamp`)
|
|
227
|
+
- `prefix` / `suffix` - Add prefix/suffix to filenames
|
|
228
|
+
- `overwrite` - Overwrite existing files (default: `false`, auto-renames if exists)
|
|
229
|
+
- `createDirectory` - Auto-create directory if missing (default: `true`)
|
|
230
|
+
|
|
156
231
|
### 📝 **Flexible Array Support**
|
|
157
232
|
|
|
158
233
|
Both `createImage()` and `createText()` methods accept **single objects** OR **arrays of objects**:
|
|
@@ -564,6 +639,9 @@ const buttonText = await painter.createText({
|
|
|
564
639
|
| `createText()` | Add text to canvas | `TextProperties \| TextProperties[]` |
|
|
565
640
|
| `createChart()` | Generate charts | `ChartConfig` |
|
|
566
641
|
| `createGIF()` | Create animated GIFs | `GIFConfig` |
|
|
642
|
+
| `save()` | Save buffer to local file with advanced options | `Buffer, SaveOptions?` |
|
|
643
|
+
| `saveMultiple()` | Save multiple buffers in batch | `Buffer[], SaveOptions?` |
|
|
644
|
+
| `resetSaveCounter()` | Reset the save counter for naming | `void` |
|
|
567
645
|
|
|
568
646
|
### 🔄 **Flexible Parameters**
|
|
569
647
|
|
|
@@ -602,6 +680,43 @@ This allows you to add multiple elements in one call for better performance and
|
|
|
602
680
|
|
|
603
681
|
---
|
|
604
682
|
|
|
683
|
+
## 🆕 What's New in v4.9.30
|
|
684
|
+
|
|
685
|
+
### 🎉 Major Feature Release
|
|
686
|
+
|
|
687
|
+
#### Background Enhancements
|
|
688
|
+
- ✨ **Video Backgrounds**: Use video frames as dynamic backgrounds
|
|
689
|
+
- 🎨 **Background Filters**: Apply filters directly to background images
|
|
690
|
+
- 🔧 **Background Opacity**: Control transparency of background images
|
|
691
|
+
|
|
692
|
+
#### Image Processing
|
|
693
|
+
- 🎭 **Image Masking**: Apply masks with multiple modes (alpha, luminance, inverse)
|
|
694
|
+
- 🔄 **Image Distortion**: Perspective, bulge, pinch, and mesh warping
|
|
695
|
+
- ✨ **Effects Stack**: Vignette, lens flare, chromatic aberration, film grain
|
|
696
|
+
- 🎛️ **Enhanced Filters**: Filter intensity and order control
|
|
697
|
+
|
|
698
|
+
#### Text Features
|
|
699
|
+
- 📐 **Text on Paths**: Render text along curves and custom paths
|
|
700
|
+
|
|
701
|
+
#### Custom Lines
|
|
702
|
+
- ➡️ **Arrow Markers**: Start/end arrows with customizable styles
|
|
703
|
+
- 📍 **Path Markers**: Add markers at any position along paths
|
|
704
|
+
- 🎨 **Line Patterns**: Dots, dashes, and custom patterns
|
|
705
|
+
- 🖼️ **Line Textures**: Apply texture images to lines
|
|
706
|
+
|
|
707
|
+
#### New Utilities
|
|
708
|
+
- ⚡ **Batch Operations**: Process multiple operations in parallel
|
|
709
|
+
- 🔗 **Chain Operations**: Chain operations sequentially
|
|
710
|
+
- 🖼️ **Image Stitching**: Combine images into panoramas
|
|
711
|
+
- 🎨 **Collage Maker**: Create beautiful image collages
|
|
712
|
+
- 📦 **Image Compression**: Optimize images with quality control
|
|
713
|
+
- 🎨 **Color Palette Extraction**: Extract color palettes from images
|
|
714
|
+
- 💾 **Advanced Save Method**: Save buffers to files with smart naming, format conversion, and batch support
|
|
715
|
+
|
|
716
|
+
See [CHANGELOG.md](CHANGELOG.md) for complete details.
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
605
720
|
## 🤝 Contributing
|
|
606
721
|
|
|
607
722
|
We welcome contributions! Here's how you can help:
|
package/apex-banner.png
ADDED
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PathLike } from "fs";
|
|
2
|
-
import { OutputFormat, CanvasConfig, TextProperties, ImageProperties, GIFOptions, GIFResults, CustomOptions, cropOptions, Frame, ExtractFramesOptions, ResizeOptions, MaskOptions, BlendOptions } from "./utils/utils";
|
|
2
|
+
import { OutputFormat, CanvasConfig, TextProperties, ImageProperties, GIFOptions, GIFResults, CustomOptions, cropOptions, GradientConfig, Frame, ExtractFramesOptions, ResizeOptions, MaskOptions, BlendOptions, ImageFilter, BatchOperation, ChainOperation, StitchOptions, CollageLayout, CompressionOptions, PaletteOptions, SaveOptions, SaveResult } from "./utils/utils";
|
|
3
3
|
interface CanvasResults {
|
|
4
4
|
buffer: Buffer;
|
|
5
5
|
canvas: CanvasConfig;
|
|
@@ -7,146 +7,23 @@ interface CanvasResults {
|
|
|
7
7
|
export declare class ApexPainter {
|
|
8
8
|
#private;
|
|
9
9
|
private format?;
|
|
10
|
+
private saveCounter;
|
|
10
11
|
constructor({ type }?: OutputFormat);
|
|
11
|
-
/**
|
|
12
|
-
* Creates a canvas with the given configuration.
|
|
13
|
-
* Applies rotation, shadow, border effects, background, and stroke.
|
|
14
|
-
*
|
|
15
|
-
* @param canvas - Canvas configuration object containing:
|
|
16
|
-
* - width: Canvas width in pixels
|
|
17
|
-
* - height: Canvas height in pixels
|
|
18
|
-
* - x: X position offset (default: 0)
|
|
19
|
-
* - y: Y position offset (default: 0)
|
|
20
|
-
* - colorBg: Solid color background (hex, rgb, rgba, hsl, etc.)
|
|
21
|
-
* - gradientBg: Gradient background configuration
|
|
22
|
-
* - customBg: Custom background image buffer
|
|
23
|
-
* - zoom: Canvas zoom level (default: 1)
|
|
24
|
-
* - pattern: Pattern background configuration
|
|
25
|
-
* - noise: Noise effect configuration
|
|
26
|
-
*
|
|
27
|
-
* @returns Promise<CanvasResults> - Object containing canvas buffer and configuration
|
|
28
|
-
*
|
|
29
|
-
* @throws Error if canvas configuration is invalid or conflicting
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const result = await painter.createCanvas({
|
|
34
|
-
* width: 800,
|
|
35
|
-
* height: 600,
|
|
36
|
-
* colorBg: '#ffffff',
|
|
37
|
-
* zoom: 1.5
|
|
38
|
-
* });
|
|
39
|
-
* const buffer = result.buffer;
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
12
|
createCanvas(canvas: CanvasConfig): Promise<CanvasResults>;
|
|
43
|
-
/**
|
|
44
|
-
* Draws one or more images (or shapes) on an existing canvas buffer.
|
|
45
|
-
*
|
|
46
|
-
* @param images - Single ImageProperties object or array of ImageProperties containing:
|
|
47
|
-
* - source: Image path/URL/Buffer or ShapeType ('rectangle', 'circle', etc.)
|
|
48
|
-
* - x: X position on canvas
|
|
49
|
-
* - y: Y position on canvas
|
|
50
|
-
* - width: Image/shape width (optional, defaults to original size)
|
|
51
|
-
* - height: Image/shape height (optional, defaults to original size)
|
|
52
|
-
* - inherit: Use original image dimensions (boolean)
|
|
53
|
-
* - fit: Image fitting mode ('fill', 'contain', 'cover', 'scale-down', 'none')
|
|
54
|
-
* - align: Image alignment ('center', 'start', 'end')
|
|
55
|
-
* - rotation: Rotation angle in degrees (default: 0)
|
|
56
|
-
* - opacity: Opacity level 0-1 (default: 1)
|
|
57
|
-
* - blur: Blur radius in pixels (default: 0)
|
|
58
|
-
* - borderRadius: Border radius or 'circular' (default: 0)
|
|
59
|
-
* - borderPosition: Border position ('all', 'top', 'bottom', 'left', 'right')
|
|
60
|
-
* - filters: Array of image filters to apply
|
|
61
|
-
* - shape: Shape properties (when source is a shape)
|
|
62
|
-
* - shadow: Shadow configuration
|
|
63
|
-
* - stroke: Stroke configuration
|
|
64
|
-
* - boxBackground: Background behind image/shape
|
|
65
|
-
*
|
|
66
|
-
* @param canvasBuffer - Existing canvas buffer (Buffer) or CanvasResults object
|
|
67
|
-
*
|
|
68
|
-
* @returns Promise<Buffer> - Updated canvas buffer in PNG format
|
|
69
|
-
*
|
|
70
|
-
* @throws Error if source, x, or y are missing
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const result = await painter.createImage([
|
|
75
|
-
* {
|
|
76
|
-
* source: 'rectangle',
|
|
77
|
-
* x: 100, y: 100,
|
|
78
|
-
* width: 200, height: 150,
|
|
79
|
-
* shape: { fill: true, color: '#ff6b6b' },
|
|
80
|
-
* shadow: { color: 'rgba(0,0,0,0.3)', offsetX: 5, offsetY: 5, blur: 10 }
|
|
81
|
-
* }
|
|
82
|
-
* ], canvasBuffer);
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
13
|
createImage(images: ImageProperties | ImageProperties[], canvasBuffer: CanvasResults | Buffer): Promise<Buffer>;
|
|
86
|
-
/**
|
|
87
|
-
* Creates text on an existing canvas buffer with enhanced styling options.
|
|
88
|
-
*
|
|
89
|
-
* @param textArray - Single TextProperties object or array of TextProperties containing:
|
|
90
|
-
* - text: Text content to render (required)
|
|
91
|
-
* - x: X position on canvas (required)
|
|
92
|
-
* - y: Y position on canvas (required)
|
|
93
|
-
* - fontPath: Path to custom font file (.ttf, .otf, .woff, etc.)
|
|
94
|
-
* - fontName: Custom font name (used with fontPath)
|
|
95
|
-
* - fontSize: Font size in pixels (default: 16)
|
|
96
|
-
* - fontFamily: Font family name (e.g., 'Arial', 'Helvetica')
|
|
97
|
-
* - bold: Make text bold (boolean)
|
|
98
|
-
* - italic: Make text italic (boolean)
|
|
99
|
-
* - underline: Add underline decoration (boolean)
|
|
100
|
-
* - overline: Add overline decoration (boolean)
|
|
101
|
-
* - strikethrough: Add strikethrough decoration (boolean)
|
|
102
|
-
* - highlight: Highlight text with background color and opacity
|
|
103
|
-
* - lineHeight: Line height multiplier (default: 1.4)
|
|
104
|
-
* - letterSpacing: Space between letters in pixels
|
|
105
|
-
* - wordSpacing: Space between words in pixels
|
|
106
|
-
* - maxWidth: Maximum width for text wrapping
|
|
107
|
-
* - maxHeight: Maximum height for text (truncates with ellipsis)
|
|
108
|
-
* - textAlign: Horizontal text alignment ('left', 'center', 'right', 'start', 'end')
|
|
109
|
-
* - textBaseline: Vertical text baseline ('alphabetic', 'bottom', 'hanging', 'ideographic', 'middle', 'top')
|
|
110
|
-
* - color: Text color (hex, rgb, rgba, hsl, etc.)
|
|
111
|
-
* - gradient: Gradient fill for text
|
|
112
|
-
* - opacity: Text opacity (0-1, default: 1)
|
|
113
|
-
* - glow: Text glow effect with color, intensity, and opacity
|
|
114
|
-
* - shadow: Text shadow effect with color, offset, blur, and opacity
|
|
115
|
-
* - stroke: Text stroke/outline with color, width, gradient, and opacity
|
|
116
|
-
* - rotation: Text rotation in degrees
|
|
117
|
-
*
|
|
118
|
-
* @param canvasBuffer - Existing canvas buffer (Buffer) or CanvasResults object
|
|
119
|
-
*
|
|
120
|
-
* @returns Promise<Buffer> - Updated canvas buffer in PNG format
|
|
121
|
-
*
|
|
122
|
-
* @throws Error if text, x, or y are missing, or if canvas buffer is invalid
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* const result = await painter.createText([
|
|
127
|
-
* {
|
|
128
|
-
* text: "Hello World!",
|
|
129
|
-
* x: 100, y: 100,
|
|
130
|
-
* fontSize: 24,
|
|
131
|
-
* bold: true,
|
|
132
|
-
* color: '#ff6b6b',
|
|
133
|
-
* shadow: { color: 'rgba(0,0,0,0.3)', offsetX: 2, offsetY: 2, blur: 4 },
|
|
134
|
-
* underline: true,
|
|
135
|
-
* highlight: { color: '#ffff00', opacity: 0.3 }
|
|
136
|
-
* }
|
|
137
|
-
* ], canvasBuffer);
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
14
|
createText(textArray: TextProperties | TextProperties[], canvasBuffer: CanvasResults | Buffer): Promise<Buffer>;
|
|
141
|
-
createCustom(options: CustomOptions[], buffer: CanvasResults | Buffer): Promise<Buffer>;
|
|
15
|
+
createCustom(options: CustomOptions | CustomOptions[], buffer: CanvasResults | Buffer): Promise<Buffer>;
|
|
142
16
|
createGIF(gifFrames: {
|
|
143
17
|
background: string;
|
|
144
18
|
duration: number;
|
|
145
|
-
}[], options: GIFOptions): Promise<GIFResults |
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
19
|
+
}[], options: GIFOptions): Promise<GIFResults | Buffer | string | Array<{
|
|
20
|
+
attachment: NodeJS.ReadableStream | any;
|
|
21
|
+
name: string;
|
|
22
|
+
}> | undefined>;
|
|
23
|
+
resize(resizeOptions: ResizeOptions): Promise<Buffer>;
|
|
24
|
+
imgConverter(source: string, newExtension: string): Promise<Buffer>;
|
|
25
|
+
effects(source: string, filters: ImageFilter[]): Promise<Buffer>;
|
|
26
|
+
colorsFilter(source: string, filterColor: string | GradientConfig, opacity?: number): Promise<Buffer>;
|
|
150
27
|
colorAnalysis(source: string): Promise<{
|
|
151
28
|
color: string;
|
|
152
29
|
frequency: string;
|
|
@@ -155,24 +32,26 @@ export declare class ApexPainter {
|
|
|
155
32
|
red: number;
|
|
156
33
|
green: number;
|
|
157
34
|
blue: number;
|
|
158
|
-
}): Promise<Buffer
|
|
159
|
-
removeBackground(imageURL: string, apiKey: string): Promise<Buffer
|
|
160
|
-
blend(layers: {
|
|
35
|
+
}): Promise<Buffer | undefined>;
|
|
36
|
+
removeBackground(imageURL: string, apiKey: string): Promise<Buffer | undefined>;
|
|
37
|
+
blend(layers: Array<{
|
|
161
38
|
image: string | Buffer;
|
|
162
|
-
blendMode:
|
|
39
|
+
blendMode: GlobalCompositeOperation;
|
|
163
40
|
position?: {
|
|
164
41
|
x: number;
|
|
165
42
|
y: number;
|
|
166
43
|
};
|
|
167
44
|
opacity?: number;
|
|
168
|
-
}
|
|
169
|
-
createChart(data:
|
|
45
|
+
}>, baseImageBuffer: Buffer, defaultBlendMode?: GlobalCompositeOperation): Promise<Buffer>;
|
|
46
|
+
createChart(data: unknown, type: {
|
|
170
47
|
chartType: string;
|
|
171
48
|
chartNumber: number;
|
|
172
|
-
}): Promise<Buffer
|
|
49
|
+
}): Promise<Buffer>;
|
|
173
50
|
cropImage(options: cropOptions): Promise<Buffer>;
|
|
174
|
-
|
|
175
|
-
|
|
51
|
+
extractFrames(videoSource: string | Buffer, options: ExtractFramesOptions): Promise<Array<{
|
|
52
|
+
source: string;
|
|
53
|
+
isRemote: boolean;
|
|
54
|
+
}>>;
|
|
176
55
|
masking(source: string | Buffer | PathLike | Uint8Array, maskSource: string | Buffer | PathLike | Uint8Array, options?: MaskOptions): Promise<Buffer>;
|
|
177
56
|
gradientBlend(source: string | Buffer | PathLike | Uint8Array, options: BlendOptions): Promise<Buffer>;
|
|
178
57
|
animate(frames: Frame[], defaultDuration: number, defaultWidth?: number, defaultHeight?: number, options?: {
|
|
@@ -182,8 +61,142 @@ export declare class ApexPainter {
|
|
|
182
61
|
onFrame?: (index: number) => void;
|
|
183
62
|
onEnd?: () => void;
|
|
184
63
|
}): Promise<Buffer[] | undefined>;
|
|
185
|
-
|
|
186
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Processes multiple operations in parallel
|
|
66
|
+
* @param operations - Array of operations to process
|
|
67
|
+
* @returns Array of result buffers
|
|
68
|
+
*/
|
|
69
|
+
batch(operations: BatchOperation[]): Promise<Buffer[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Chains multiple operations sequentially
|
|
72
|
+
* @param operations - Array of operations to chain
|
|
73
|
+
* @returns Final result buffer
|
|
74
|
+
*/
|
|
75
|
+
chain(operations: ChainOperation[]): Promise<Buffer>;
|
|
76
|
+
/**
|
|
77
|
+
* Stitches multiple images together
|
|
78
|
+
* @param images - Array of image sources
|
|
79
|
+
* @param options - Stitching options
|
|
80
|
+
* @returns Stitched image buffer
|
|
81
|
+
*/
|
|
82
|
+
stitchImages(images: Array<string | Buffer>, options?: StitchOptions): Promise<Buffer>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates an image collage
|
|
85
|
+
* @param images - Array of image sources with optional dimensions
|
|
86
|
+
* @param layout - Collage layout configuration
|
|
87
|
+
* @returns Collage image buffer
|
|
88
|
+
*/
|
|
89
|
+
createCollage(images: Array<{
|
|
90
|
+
source: string | Buffer;
|
|
91
|
+
width?: number;
|
|
92
|
+
height?: number;
|
|
93
|
+
}>, layout: CollageLayout): Promise<Buffer>;
|
|
94
|
+
/**
|
|
95
|
+
* Compresses an image with quality control
|
|
96
|
+
* @param image - Image source (path, URL, or Buffer)
|
|
97
|
+
* @param options - Compression options
|
|
98
|
+
* @returns Compressed image buffer
|
|
99
|
+
*/
|
|
100
|
+
compress(image: string | Buffer, options?: CompressionOptions): Promise<Buffer>;
|
|
101
|
+
/**
|
|
102
|
+
* Extracts color palette from an image
|
|
103
|
+
* @param image - Image source (path, URL, or Buffer)
|
|
104
|
+
* @param options - Palette extraction options
|
|
105
|
+
* @returns Array of colors with percentages
|
|
106
|
+
*/
|
|
107
|
+
extractPalette(image: string | Buffer, options?: PaletteOptions): Promise<Array<{
|
|
108
|
+
color: string;
|
|
109
|
+
percentage: number;
|
|
110
|
+
}>>;
|
|
111
|
+
/**
|
|
112
|
+
* Validates a hexadecimal color string.
|
|
113
|
+
* @param hexColor - Hexadecimal color string to validate (format: #RRGGBB)
|
|
114
|
+
* @returns True if the color is valid
|
|
115
|
+
* @throws Error if the color format is invalid
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* painter.validHex('#ff0000'); // true
|
|
120
|
+
* painter.validHex('#FF00FF'); // true
|
|
121
|
+
* painter.validHex('invalid'); // throws Error
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
validHex(hexColor: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Converts results to the configured output format.
|
|
127
|
+
* @param results - Buffer or result to convert
|
|
128
|
+
* @returns Converted result in the configured format
|
|
129
|
+
* @throws Error if format is unsupported or conversion fails
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const painter = new ApexPainter({ type: 'base64' });
|
|
134
|
+
* const result = await painter.createCanvas({ width: 100, height: 100 });
|
|
135
|
+
* const base64String = await painter.outPut(result.buffer); // Returns base64 string
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
outPut(results: Buffer): Promise<Buffer | string | Blob | ArrayBuffer>;
|
|
139
|
+
/**
|
|
140
|
+
* Advanced save method to save buffers to local files with extensive customization options.
|
|
141
|
+
*
|
|
142
|
+
* @param buffer - Buffer to save (from createCanvas, createImage, createText, etc.)
|
|
143
|
+
* @param options - Save options for file path, format, naming, etc.
|
|
144
|
+
* @returns SaveResult with file path, name, size, and format
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* // Simple save with auto-generated name
|
|
149
|
+
* const canvas = await painter.createCanvas({ width: 800, height: 600 });
|
|
150
|
+
* const result = await painter.save(canvas.buffer);
|
|
151
|
+
* // Saves to: ./ApexPainter_output/20241220_143025_123.png
|
|
152
|
+
*
|
|
153
|
+
* // Custom filename and directory
|
|
154
|
+
* await painter.save(canvas.buffer, {
|
|
155
|
+
* directory: './my-images',
|
|
156
|
+
* filename: 'my-canvas',
|
|
157
|
+
* format: 'jpg',
|
|
158
|
+
* quality: 95
|
|
159
|
+
* });
|
|
160
|
+
*
|
|
161
|
+
* // Save with counter naming
|
|
162
|
+
* await painter.save(canvas.buffer, {
|
|
163
|
+
* naming: 'counter',
|
|
164
|
+
* prefix: 'image-',
|
|
165
|
+
* counterStart: 1
|
|
166
|
+
* });
|
|
167
|
+
* // Saves to: ./ApexPainter_output/image-1.png, image-2.png, etc.
|
|
168
|
+
*
|
|
169
|
+
* // Save multiple buffers
|
|
170
|
+
* const buffers = [canvas1.buffer, canvas2.buffer, canvas3.buffer];
|
|
171
|
+
* const results = await painter.saveMultiple(buffers, {
|
|
172
|
+
* prefix: 'batch-',
|
|
173
|
+
* naming: 'counter'
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
save(buffer: Buffer, options?: SaveOptions): Promise<SaveResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Save multiple buffers at once with batch options.
|
|
180
|
+
*
|
|
181
|
+
* @param buffers - Array of buffers to save
|
|
182
|
+
* @param options - Save options (applied to all files)
|
|
183
|
+
* @returns Array of SaveResult objects
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const canvas1 = await painter.createCanvas({ width: 800, height: 600 });
|
|
188
|
+
* const canvas2 = await painter.createCanvas({ width: 800, height: 600 });
|
|
189
|
+
* const results = await painter.saveMultiple([canvas1.buffer, canvas2.buffer], {
|
|
190
|
+
* prefix: 'batch-',
|
|
191
|
+
* naming: 'counter'
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
saveMultiple(buffers: Buffer[], options?: SaveOptions): Promise<SaveResult[]>;
|
|
196
|
+
/**
|
|
197
|
+
* Reset the save counter (useful when using 'counter' naming).
|
|
198
|
+
*/
|
|
199
|
+
resetSaveCounter(): void;
|
|
187
200
|
}
|
|
188
201
|
export {};
|
|
189
202
|
//# sourceMappingURL=ApexPainter.d.ts.map
|