@rosepetal/node-red-contrib-image-tools 1.1.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.
Files changed (131) hide show
  1. package/.gitattributes +6 -0
  2. package/.github/workflows/build-prebuild.yml +326 -0
  3. package/LICENSE +13 -0
  4. package/README.md +161 -0
  5. package/artifacts/darwin-arm64/package.json +25 -0
  6. package/artifacts/linux-arm64/package.json +26 -0
  7. package/artifacts/linux-x64/package.json +26 -0
  8. package/artifacts/linuxmusl-x64/package.json +26 -0
  9. package/assets/flow_time_example.gif +0 -0
  10. package/assets/nodes/io/array-in-demo.gif +0 -0
  11. package/assets/nodes/io/array-out-demo.gif +0 -0
  12. package/assets/nodes/io/array-select-demo.gif +0 -0
  13. package/assets/nodes/io/image-in-demo.gif +0 -0
  14. package/assets/nodes/mix/concat-demo.gif +0 -0
  15. package/assets/nodes/mix/mosaic-demo.gif +0 -0
  16. package/assets/nodes/transform/crop-demo.gif +0 -0
  17. package/assets/nodes/transform/filter-demo.gif +0 -0
  18. package/assets/nodes/transform/padding-demo.gif +0 -0
  19. package/assets/nodes/transform/resize-demo.gif +0 -0
  20. package/assets/nodes/transform/rotate-demo.gif +0 -0
  21. package/docs/nodes/blend/add-mask.md +275 -0
  22. package/docs/nodes/blend/add-masks.md +284 -0
  23. package/docs/nodes/blend/blend.md +248 -0
  24. package/docs/nodes/io/array-in.md +119 -0
  25. package/docs/nodes/io/array-out.md +150 -0
  26. package/docs/nodes/io/array-select.md +157 -0
  27. package/docs/nodes/io/image-in.md +131 -0
  28. package/docs/nodes/io/image-out.md +179 -0
  29. package/docs/nodes/io/queue.md +57 -0
  30. package/docs/nodes/io/save-file.md +30 -0
  31. package/docs/nodes/mix/advanced-mosaic.md +108 -0
  32. package/docs/nodes/mix/concat.md +127 -0
  33. package/docs/nodes/mix/mosaic.md +146 -0
  34. package/docs/nodes/specialized/cropBB.md +271 -0
  35. package/docs/nodes/specialized/image-align.md +426 -0
  36. package/docs/nodes/transform/crop.md +132 -0
  37. package/docs/nodes/transform/draw.md +77 -0
  38. package/docs/nodes/transform/filter.md +84 -0
  39. package/docs/nodes/transform/padding.md +133 -0
  40. package/docs/nodes/transform/resize.md +158 -0
  41. package/docs/nodes/transform/rotate.md +121 -0
  42. package/docs/nodes/util/block-detect.md +46 -0
  43. package/install.sh +144 -0
  44. package/node-red-contrib-image-tools/lib/cpp-bridge.js +224 -0
  45. package/node-red-contrib-image-tools/lib/node-utils.js +529 -0
  46. package/node-red-contrib-image-tools/nodes/blend/add-bbs.html +590 -0
  47. package/node-red-contrib-image-tools/nodes/blend/add-bbs.js +241 -0
  48. package/node-red-contrib-image-tools/nodes/blend/add-mask.html +449 -0
  49. package/node-red-contrib-image-tools/nodes/blend/add-mask.js +170 -0
  50. package/node-red-contrib-image-tools/nodes/blend/add-masks.html +703 -0
  51. package/node-red-contrib-image-tools/nodes/blend/add-masks.js +321 -0
  52. package/node-red-contrib-image-tools/nodes/blend/blend.html +552 -0
  53. package/node-red-contrib-image-tools/nodes/blend/blend.js +124 -0
  54. package/node-red-contrib-image-tools/nodes/io/array-in.html +110 -0
  55. package/node-red-contrib-image-tools/nodes/io/array-in.js +113 -0
  56. package/node-red-contrib-image-tools/nodes/io/array-out.html +125 -0
  57. package/node-red-contrib-image-tools/nodes/io/array-out.js +213 -0
  58. package/node-red-contrib-image-tools/nodes/io/array-select.html +156 -0
  59. package/node-red-contrib-image-tools/nodes/io/array-select.js +187 -0
  60. package/node-red-contrib-image-tools/nodes/io/folder-in.html +248 -0
  61. package/node-red-contrib-image-tools/nodes/io/folder-in.js +335 -0
  62. package/node-red-contrib-image-tools/nodes/io/image-in.html +146 -0
  63. package/node-red-contrib-image-tools/nodes/io/image-in.js +143 -0
  64. package/node-red-contrib-image-tools/nodes/io/image-out.html +506 -0
  65. package/node-red-contrib-image-tools/nodes/io/image-out.js +545 -0
  66. package/node-red-contrib-image-tools/nodes/io/queue.html +119 -0
  67. package/node-red-contrib-image-tools/nodes/io/queue.js +191 -0
  68. package/node-red-contrib-image-tools/nodes/io/save-file.html +243 -0
  69. package/node-red-contrib-image-tools/nodes/io/save-file.js +440 -0
  70. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +2149 -0
  71. package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.js +195 -0
  72. package/node-red-contrib-image-tools/nodes/mix/concat.html +390 -0
  73. package/node-red-contrib-image-tools/nodes/mix/concat.js +112 -0
  74. package/node-red-contrib-image-tools/nodes/mix/mosaic.html +550 -0
  75. package/node-red-contrib-image-tools/nodes/mix/mosaic.js +151 -0
  76. package/node-red-contrib-image-tools/nodes/specialized/cropBB.html +268 -0
  77. package/node-red-contrib-image-tools/nodes/specialized/cropBB.js +277 -0
  78. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +528 -0
  79. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +306 -0
  80. package/node-red-contrib-image-tools/nodes/transform/crop.html +410 -0
  81. package/node-red-contrib-image-tools/nodes/transform/crop.js +149 -0
  82. package/node-red-contrib-image-tools/nodes/transform/draw.html +719 -0
  83. package/node-red-contrib-image-tools/nodes/transform/draw.js +509 -0
  84. package/node-red-contrib-image-tools/nodes/transform/filter.html +578 -0
  85. package/node-red-contrib-image-tools/nodes/transform/filter.js +177 -0
  86. package/node-red-contrib-image-tools/nodes/transform/padding.html +475 -0
  87. package/node-red-contrib-image-tools/nodes/transform/padding.js +142 -0
  88. package/node-red-contrib-image-tools/nodes/transform/resize.html +429 -0
  89. package/node-red-contrib-image-tools/nodes/transform/resize.js +162 -0
  90. package/node-red-contrib-image-tools/nodes/transform/rotate.html +299 -0
  91. package/node-red-contrib-image-tools/nodes/transform/rotate.js +141 -0
  92. package/node-red-contrib-image-tools/nodes/util/block-detect.html +85 -0
  93. package/node-red-contrib-image-tools/nodes/util/block-detect.js +136 -0
  94. package/node-red-contrib-image-tools/nodes/util/clean-debug.html +201 -0
  95. package/node-red-contrib-image-tools/nodes/util/clean-debug.js +393 -0
  96. package/node-red-contrib-image-tools/package.json +64 -0
  97. package/npm/darwin-arm64/lib/.gitkeep +1 -0
  98. package/npm/darwin-arm64/package.json +25 -0
  99. package/npm/darwin-x64/lib/.gitkeep +1 -0
  100. package/npm/darwin-x64/package.json +25 -0
  101. package/npm/linux-arm64/lib/.gitkeep +1 -0
  102. package/npm/linux-arm64/package.json +26 -0
  103. package/npm/linux-x64/lib/.gitkeep +1 -0
  104. package/npm/linux-x64/package.json +26 -0
  105. package/npm/linuxmusl-x64/lib/.gitkeep +1 -0
  106. package/npm/linuxmusl-x64/package.json +26 -0
  107. package/npm/win32-x64/lib/.gitkeep +1 -0
  108. package/npm/win32-x64/package.json +25 -0
  109. package/package.json +74 -0
  110. package/rosepetal-image-engine/binding.gyp +153 -0
  111. package/rosepetal-image-engine/package.json +19 -0
  112. package/rosepetal-image-engine/src/add-bbs.cpp +433 -0
  113. package/rosepetal-image-engine/src/add-mask.cpp +240 -0
  114. package/rosepetal-image-engine/src/add-masks.cpp +638 -0
  115. package/rosepetal-image-engine/src/advanced-mosaic.cpp +740 -0
  116. package/rosepetal-image-engine/src/blend.cpp +200 -0
  117. package/rosepetal-image-engine/src/concat.cpp +329 -0
  118. package/rosepetal-image-engine/src/crop.cpp +139 -0
  119. package/rosepetal-image-engine/src/draw.cpp +414 -0
  120. package/rosepetal-image-engine/src/filter.cpp +230 -0
  121. package/rosepetal-image-engine/src/filters/kernels.h +171 -0
  122. package/rosepetal-image-engine/src/image-align.cpp +551 -0
  123. package/rosepetal-image-engine/src/main.cpp +36 -0
  124. package/rosepetal-image-engine/src/mosaic.cpp +373 -0
  125. package/rosepetal-image-engine/src/padding.cpp +124 -0
  126. package/rosepetal-image-engine/src/resize.cpp +210 -0
  127. package/rosepetal-image-engine/src/rotate.cpp +177 -0
  128. package/rosepetal-image-engine/src/utils.h +563 -0
  129. package/rosepetal-image-engine/test-formats.js +119 -0
  130. package/scripts/build-opencv-static.ps1 +166 -0
  131. package/scripts/build-opencv-static.sh +147 -0
@@ -0,0 +1,84 @@
1
+ # Filter Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `filter` node applies various image processing filters for enhancement, artistic effects, and image analysis. It provides optimized implementations of common filters including blur, sharpen, edge detection, emboss, and Gaussian operations.
6
+
7
+ **Real-World Applications:**
8
+ - **Photo Enhancement**: Sharpen portraits and improve image quality
9
+ - **Artistic Effects**: Create stylized images with emboss and edge effects
10
+ - **Quality Control**: Use edge detection to analyze product shapes and boundaries
11
+ - **Medical Imaging**: Enhance contrast and details in diagnostic images
12
+ - **Preprocessing**: Prepare images for AI analysis with noise reduction and enhancement
13
+
14
+ ![Filter Demo](../../../assets/nodes/transform/filter-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Single Image**: Standard image object format
20
+ - **Image Array**: Array of image objects for batch filtering
21
+ - **Dynamic Parameters**: Filter strength and settings via message properties
22
+
23
+ ### Outputs
24
+ - **Filtered Image**: Image with applied filter effects
25
+ - **Preserved Dimensions**: Output maintains original image dimensions
26
+ - **Format Options**: Raw image object or encoded file formats
27
+
28
+ ## Configuration Options
29
+
30
+ ### Input/Output Paths
31
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
32
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
33
+
34
+ ### Filter Types
35
+
36
+ #### Blur Filter
37
+ - **Purpose**: Reduces image noise and creates soft focus effects
38
+ - **Strength**: Configurable blur radius
39
+ - **Use Cases**: Noise reduction, background softening, privacy protection
40
+
41
+ #### Sharpen Filter
42
+ - **Purpose**: Enhances image details and edge definition
43
+ - **Strength**: Configurable sharpening intensity
44
+ - **Use Cases**: Photo enhancement, print preparation, detail emphasis
45
+
46
+ #### Edge Detection
47
+ - **Purpose**: Highlights edges and boundaries in images
48
+ - **Output**: Binary or grayscale edge maps
49
+ - **Use Cases**: Object detection, shape analysis, contour extraction
50
+
51
+ #### Emboss Filter
52
+ - **Purpose**: Creates 3D relief effect with depth appearance
53
+ - **Direction**: Configurable embossing direction
54
+ - **Use Cases**: Artistic effects, texture analysis, decorative processing
55
+
56
+ #### Gaussian Blur
57
+ - **Purpose**: Smooth blur with natural falloff
58
+ - **Sigma**: Configurable standard deviation for blur amount
59
+ - **Use Cases**: Background blur, noise reduction, preprocessing
60
+
61
+ ### Filter Strength/Parameters
62
+ - **Range**: Varies by filter type
63
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
64
+ - **Dynamic**: Runtime adjustment via message properties
65
+
66
+ ### Output Format Options
67
+ - **Raw**: Standard image object (fastest for processing chains)
68
+ - **JPEG**: Compressed with quality control
69
+ - **PNG**: Lossless preservation of filter effects
70
+ - **WebP**: Modern format with excellent compression
71
+
72
+ ## Performance Notes
73
+
74
+ ### C++ Backend Processing
75
+ - **Optimized Kernels**: Hand-tuned convolution implementations
76
+ - **OpenCV Integration**: Leverages OpenCV's optimized filter functions
77
+ - **Memory Efficient**: In-place processing where possible
78
+ - **Parallel Execution**: Multi-threaded processing for large images
79
+
80
+ ### Filter-Specific Performance
81
+ - **Blur/Gaussian**: Linear time complexity with kernel size
82
+ - **Sharpen**: Fast single-pass convolution
83
+ - **Edge Detection**: Sobel or Canny edge detection algorithms
84
+ - **Emboss**: Single convolution pass with directional kernel
@@ -0,0 +1,133 @@
1
+ # Padding Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `padding` node adds margins around images with configurable colors and dimensions. It expands the canvas size while preserving the original image content, perfect for creating borders, standardizing dimensions, or preparing images for specific layouts.
6
+
7
+ **Real-World Applications:**
8
+ - **Social Media Formatting**: Add borders for consistent post dimensions
9
+ - **Print Preparation**: Add bleed areas and margins for professional printing
10
+ - **Gallery Display**: Create uniform frames for image collections
11
+ - **Logo Branding**: Add branded borders around product images
12
+ - **Document Layout**: Add margins for text overlay or annotations
13
+
14
+ ![Padding Demo](../../../assets/nodes/transform/padding-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Single Image**: Standard image object format
20
+ - **Image Array**: Array of image objects for batch padding
21
+ - **Dynamic Values**: Padding dimensions can be provided via message properties
22
+
23
+ ### Outputs
24
+ - **Padded Image**: Original image with added margins
25
+ - **Expanded Dimensions**: Canvas size increased by padding amounts
26
+ - **Format Options**: Raw image object or encoded file formats
27
+
28
+ ## Configuration Options
29
+
30
+ ### Input/Output Paths
31
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
32
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
33
+
34
+ ### Padding Dimensions
35
+
36
+ #### Top Padding
37
+ - **Type**: Pixels (integer)
38
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
39
+ - **Effect**: Adds space above the image
40
+
41
+ #### Right Padding
42
+ - **Type**: Pixels (integer)
43
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
44
+ - **Effect**: Adds space to the right of the image
45
+
46
+ #### Bottom Padding
47
+ - **Type**: Pixels (integer)
48
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
49
+ - **Effect**: Adds space below the image
50
+
51
+ #### Left Padding
52
+ - **Type**: Pixels (integer)
53
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
54
+ - **Effect**: Adds space to the left of the image
55
+
56
+ ### Color Configuration
57
+
58
+ #### Padding Color
59
+ - **Formats Supported**:
60
+ - RGB: `rgb(255,0,0)`, `rgb(255,255,255)`
61
+ - **Default**: Black
62
+
63
+ ### Output Format Options
64
+ - **Raw**: Standard image object (fastest for processing chains)
65
+ - **JPEG**: Compressed (note: transparency becomes white)
66
+ - **PNG**: Lossless with full transparency support
67
+ - **WebP**: Modern format with transparency support
68
+
69
+ ## Performance Notes
70
+
71
+ ### C++ Backend Processing
72
+ - **Efficient Canvas Expansion**: Optimized memory allocation for padded dimensions
73
+ - **Color Fill**: Fast uniform color filling using OpenCV
74
+ - **Memory Management**: Minimal memory overhead for padding operations
75
+ - **Batch Processing**: Array inputs processed in parallel
76
+
77
+ ### Dimension Calculations
78
+ - **New Width**: Original width + left padding + right padding
79
+ - **New Height**: Original height + top padding + bottom padding
80
+
81
+ ## Real-World Examples
82
+
83
+ ### Social Media Post Creation
84
+ ```
85
+ [Image-In: product.jpg] → [Padding: 50px all sides, Brand color] → [Social Post]
86
+ ```
87
+ Add branded borders for consistent social media appearance.
88
+
89
+ ### Print Preparation
90
+ ```
91
+ [Photo] → [Padding: Top=100, Right=50, Bottom=100, Left=50, White] → [Print Ready]
92
+ ```
93
+ Add margins for professional printing with bleed areas.
94
+
95
+ ### Gallery Standardization
96
+ ```
97
+ [Image Array] → [Padding: Equal margins, White] → [Uniform Gallery]
98
+ ```
99
+ Create consistent framing for image galleries.
100
+
101
+ ### Logo Watermarking Prep
102
+ ```
103
+ [Product Image] → [Padding: Bottom=80, White] → [Ready for Logo Overlay]
104
+ ```
105
+ Add space for logo placement with white background.
106
+
107
+ ### Document Border Creation
108
+ ```
109
+ [Document Scan] → [Padding: 20px all sides, Light gray] → [Bordered Document]
110
+ ```
111
+ Add subtle borders to scanned documents.
112
+
113
+ ## Common Issues & Troubleshooting
114
+
115
+ ### Transparency Issues
116
+ - **Issue**: Transparent padding appears white in JPEG
117
+ - **Solution**: Use PNG or WebP format for transparency support
118
+ - **Workaround**: Match padding color to expected background
119
+
120
+ ### Large File Sizes
121
+ - **Issue**: Padding significantly increases file size
122
+ - **Cause**: Expanded canvas dimensions
123
+ - **Solution**: Use appropriate compression settings, consider if padding is necessary
124
+
125
+ ### Color Matching Problems
126
+ - **Issue**: Padding color doesn't match expected appearance
127
+ - **Solution**: Use exact color specifications (RGB codes)
128
+ - **Testing**: Use debug mode to verify color appearance
129
+
130
+ ### Dynamic Dimension Errors
131
+ - **Issue**: Invalid padding values from message properties
132
+ - **Solution**: Validate that dynamic sources contain positive integers
133
+ - **Safety**: Add bounds checking in upstream nodes
@@ -0,0 +1,158 @@
1
+ # Resize Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `resize` node provides high-performance image scaling with flexible dimension control and automatic aspect ratio preservation. It supports both fixed dimensions and proportional scaling using optimized C++ backend processing.
6
+
7
+ **Real-World Applications:**
8
+ - **Web Image Optimization**: Scale images for different device sizes and bandwidths
9
+ - **Thumbnail Generation**: Create preview images and gallery thumbnails
10
+ - **Print Preparation**: Resize images to specific print dimensions
11
+ - **Storage Optimization**: Reduce image sizes to save storage space
12
+ - **Performance Enhancement**: Optimize image sizes for faster loading
13
+
14
+ ![Resize Demo](../../../assets/nodes/transform/resize-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Single Image**: Standard image object format
20
+ - **Image Array**: Array of image objects for batch processing
21
+ - **Dynamic Dimensions**: Dimensions can be provided via message properties
22
+
23
+ ### Input Image Format
24
+ ```javascript
25
+ {
26
+ data: Buffer, // Raw pixel data
27
+ width: number, // Original width in pixels
28
+ height: number, // Original height in pixels
29
+ channels: number, // Channel count (1, 3, 4)
30
+ colorSpace: string, // "GRAY", "RGB", "RGBA"
31
+ dtype: string // "uint8"
32
+ }
33
+ ```
34
+
35
+ ### Outputs
36
+ Output format depends on the Output Format setting:
37
+ - **Raw**: Standard image object (fastest for processing chains)
38
+ - **JPEG/PNG/WebP**: Encoded file buffer ready for storage/transmission
39
+
40
+ ## Configuration Options
41
+
42
+ ### Input/Output Paths
43
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
44
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
45
+ - **Purpose**: Flexible data routing for complex workflows
46
+
47
+ ### Dimension Configuration
48
+
49
+ #### Width Settings
50
+ - **Mode**:
51
+ - **Set to**: Fixed pixel value (e.g., 800 pixels)
52
+ - **Multiply by**: Scale factor (e.g., 0.5 for half size)
53
+ - **Value Sources**:
54
+ - **Number**: Fixed value
55
+ - **msg.***: Dynamic from message property
56
+ - **flow.***: From flow context
57
+ - **global.***: From global context
58
+ - **Auto Mode**: Leave empty for automatic aspect ratio preservation
59
+
60
+ #### Height Settings
61
+ - **Mode**: Same options as width (Set to / Multiply by)
62
+ - **Value Sources**: Same dynamic options as width
63
+ - **Auto Mode**: Leave empty for proportional scaling
64
+
65
+ ### Output Format Options
66
+
67
+ #### Raw Format (Default)
68
+ - **Performance**: Fastest option for processing chains
69
+ - **Use Case**: When passing to other transform nodes
70
+
71
+ #### JPEG Format
72
+ - **Quality**: 1-100 (default: 90)
73
+ - **Use Case**: Final output, web optimization
74
+ - **Compression**: Lossy, smaller file sizes
75
+
76
+ #### PNG Format
77
+ - **Optimize**: Checkbox for additional compression
78
+ - **Use Case**: When transparency needed or lossless required
79
+ - **Compression**: Lossless
80
+
81
+ #### WebP Format
82
+ - **Quality**: 1-100 (default: 90)
83
+ - **Use Case**: Modern web applications
84
+ - **Compression**: Superior to JPEG at same quality
85
+
86
+ ### Debug Options
87
+ - **Show Processed Image**: Visual preview in Node-RED editor
88
+ - **Debug Width**: Preview image width in pixels
89
+ - **Interactive**: Click preview to hide
90
+
91
+ ## Performance Notes
92
+
93
+ ### C++ Backend Optimization
94
+ - **High-Speed Processing**: OpenCV-based scaling algorithms
95
+ - **Memory Efficient**: Optimized memory management for large images
96
+ - **Parallel Processing**: Array inputs processed concurrently
97
+ - **Algorithm**: Uses high-quality interpolation for best results
98
+
99
+ ### Processing Modes
100
+ - **Batch Processing**: Arrays processed in parallel for maximum throughput
101
+ - **Async Operations**: Non-blocking processing with timing display
102
+ - **Status Display**: Real-time processing time and result information
103
+
104
+ ## Real-World Examples
105
+
106
+ ### Web Image Optimization
107
+ ```
108
+ [Image-In: original.jpg] → [Resize: 800x600] → [Save: web_optimized.jpg]
109
+ ```
110
+ Create web-optimized versions of high-resolution images.
111
+
112
+ ### Responsive Image Set
113
+ ```
114
+ [Image-In] → [Resize: 1200x Auto] → [JPEG Quality 80] → [Large]
115
+ → [Resize: 800x Auto] → [JPEG Quality 85] → [Medium]
116
+ → [Resize: 400x Auto] → [JPEG Quality 90] → [Small]
117
+ ```
118
+ Generate multiple sizes for responsive web design.
119
+
120
+ ### Thumbnail Generation
121
+ ```
122
+ [Image Array] → [Resize: 150x150] → [PNG] → [Thumbnail Gallery]
123
+ ```
124
+ Create square thumbnails from image collections.
125
+
126
+ ### Batch Photo Processing
127
+ ```
128
+ [Photo Collection] → [Resize: Multiply 0.7] → [Save Reduced]
129
+ ```
130
+ Reduce photo sizes by 30% for storage optimization.
131
+
132
+ ### Dynamic Sizing
133
+ ```
134
+ [Set msg.targetWidth] → [Resize: Set to msg.targetWidth, Auto height] → [Output]
135
+ ```
136
+ Resize based on runtime requirements.
137
+
138
+ ## Common Issues & Troubleshooting
139
+
140
+ ### Aspect Ratio Distortion
141
+ - **Issue**: Images appear stretched or squashed
142
+ - **Cause**: Both width and height set without considering aspect ratio
143
+ - **Solution**: Leave one dimension empty for auto-calculation
144
+
145
+ ### Memory Issues with Large Images
146
+ - **Issue**: Processing very large images causes performance problems
147
+ - **Solution**: Process in batches or reduce dimensions incrementally
148
+ - **Best Practice**: Consider source image size vs. target size
149
+
150
+ ### Quality vs. File Size Balance
151
+ - **Issue**: Output files too large or quality too low
152
+ - **Solution**: Adjust quality settings (80-95 for good balance)
153
+ - **Format Choice**: Use WebP for best compression, PNG for transparency
154
+
155
+ ### Dynamic Value Errors
156
+ - **Issue**: Runtime errors when using message properties
157
+ - **Solution**: Validate dynamic values exist and are valid numbers
158
+ - **Debugging**: Use debug nodes to verify property values
@@ -0,0 +1,121 @@
1
+ # Rotate Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `rotate` node provides precise image rotation with customizable padding and background colors. It supports both clockwise and counter-clockwise rotation with automatic canvas adjustment to prevent clipping.
6
+
7
+ **Real-World Applications:**
8
+ - **Photo Orientation**: Correct camera orientation issues
9
+ - **Document Processing**: Straighten scanned documents and receipts
10
+ - **Artistic Effects**: Create artistic compositions with angled elements
11
+ - **Quality Control**: Align products for consistent photography
12
+ - **Medical Imaging**: Orient medical scans for proper analysis
13
+
14
+ ![Rotate Demo](../../../assets/nodes/transform/rotate-demo.gif)
15
+
16
+ ## Input/Output Specification
17
+
18
+ ### Inputs
19
+ - **Single Image**: Standard image object format
20
+ - **Image Array**: Array of image objects for batch rotation
21
+ - **Dynamic Angles**: Rotation angle can be provided via message properties
22
+
23
+ ### Outputs
24
+ - **Rotated Image**: Image rotated by specified angle with expanded canvas
25
+ - **Format Options**: Raw image object or encoded file formats
26
+
27
+ ## Configuration Options
28
+
29
+ ### Input/Output Paths
30
+ - **Input From**: `msg.payload` (default), `flow.*`, `global.*`
31
+ - **Output To**: `msg.payload` (default), `flow.*`, `global.*`
32
+
33
+ ### Rotation Settings
34
+
35
+ #### Angle
36
+ - **Range**: 0-360 degrees (or negative for counter-clockwise)
37
+ - **Precision**: Floating-point precision (e.g., 15.5 degrees)
38
+ - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
39
+ - **Direction**: Positive = clockwise, Negative = counter-clockwise
40
+
41
+ #### Padding Settings
42
+ - **Background Color**: Color to fill expanded canvas areas
43
+ - **Color Formats**:
44
+ - Hex: `#FF0000` (red)
45
+ - RGB: `rgb(255,0,0)`
46
+ - Named: `red`, `white`, `black`, `transparent`
47
+ - **Default**: Black background
48
+
49
+ ### Output Format Options
50
+ - **Raw**: Standard image object (fastest for processing chains)
51
+ - **JPEG**: Compressed with quality control (1-100)
52
+ - **PNG**: Lossless with transparency support
53
+ - **WebP**: Modern format with quality control
54
+
55
+ ## Performance Notes
56
+
57
+ ### C++ Backend Processing
58
+ - **High-Quality Rotation**: Uses OpenCV's optimized rotation algorithms
59
+ - **Canvas Expansion**: Automatic canvas sizing to prevent clipping
60
+ - **Memory Management**: Efficient handling of rotated image dimensions
61
+ - **Interpolation**: High-quality pixel interpolation for smooth results
62
+
63
+ ### Processing Characteristics
64
+ - **Canvas Growth**: Output image may be larger than input to accommodate rotation
65
+ - **Edge Handling**: Configurable background fill for exposed areas
66
+ - **Precision**: Sub-pixel accuracy for precise angle control
67
+
68
+ ## Real-World Examples
69
+
70
+ ### Photo Orientation Correction
71
+ ```
72
+ [Image-In: rotated_photo.jpg] → [Rotate: -90°] → [Corrected Photo]
73
+ ```
74
+ Fix photos taken with rotated camera orientation.
75
+
76
+ ### Document Straightening
77
+ ```
78
+ [Scanned Document] → [Rotate: 2.3°, White background] → [Straight Document]
79
+ ```
80
+ Correct slight rotation in scanned documents.
81
+
82
+ ### Batch Photo Processing
83
+ ```
84
+ [Photo Array] → [Rotate: msg.orientation] → [Corrected Photos]
85
+ ```
86
+ Apply different rotation angles based on EXIF data.
87
+
88
+ ### Artistic Composition
89
+ ```
90
+ [Logo Image] → [Rotate: 45°, Transparent background] → [Diamond Logo]
91
+ ```
92
+ Create artistic rotated elements with transparency.
93
+
94
+ ### Dynamic Rotation
95
+ ```
96
+ [Analysis] → [Calculate Angle] → [Rotate: msg.correctionAngle] → [Aligned Image]
97
+ ```
98
+ Rotate based on image analysis results.
99
+
100
+ ## Common Issues & Troubleshooting
101
+
102
+ ### Image Size Changes
103
+ - **Issue**: Output image larger than input
104
+ - **Cause**: Canvas expansion to accommodate rotated content
105
+ - **Expected**: Normal behavior to prevent clipping
106
+ - **Solution**: Consider downstream processing for size constraints
107
+
108
+ ### Background Color Issues
109
+ - **Issue**: Unexpected background colors in rotated areas
110
+ - **Solution**: Specify appropriate background color for your use case
111
+ - **Transparency**: Use PNG format with transparent background for overlays
112
+
113
+ ### Performance with Large Angles
114
+ - **Issue**: Significant rotation (close to 45°, 135°, etc.) creates much larger images
115
+ - **Optimization**: Consider if rotation is necessary or can be minimized
116
+ - **Memory**: Monitor memory usage with very large images
117
+
118
+ ### Precision vs. Speed
119
+ - **Issue**: High-precision angles may be slower
120
+ - **Balance**: Use appropriate precision for your requirements
121
+ - **Optimization**: Round to nearest degree if precision not critical
@@ -0,0 +1,46 @@
1
+ # Block Detect Node
2
+
3
+ ## Purpose & Use Cases
4
+
5
+ The `block-detect` node gives you a lightweight watchdog that keeps an eye on Node-RED's event loop. When long running synchronous work or runaway CPU usage blocks the event loop, flows become sluggish, timers fire late, and HTTP endpoints stall. Dropping this node anywhere in your workspace makes it easy to detect those situations without wiring any messages.
6
+
7
+ **Typical scenarios**
8
+
9
+ - **Production health checks** — raise a warning in the runtime log when flows or custom code keep the event loop busy for too long.
10
+ - **Profiling new nodes** — temporarily add the node next to experimental flows to confirm they remain non-blocking.
11
+ - **Shared environments** — monitor collaborative / multi-tenant Node-RED instances for noisy neighbours that block everyone else.
12
+
13
+ ## How It Works
14
+
15
+ - The node samples the Node.js [`monitorEventLoopDelay`](https://nodejs.org/api/perf_hooks.html#perf_hooks_monitor_event_loop_delay_options) histogram every *N* milliseconds (default one second).
16
+ - When the measured delay exceeds the configured threshold for a number of consecutive samples, the node writes an alert to the runtime log (`warn`, `error`, or plain `log`) and changes its editor status to red.
17
+ - If `monitorEventLoopDelay` is unavailable (very old Node.js builds), it falls back to measuring timer drift, which still provides a useful signal with minimal CPU overhead.
18
+ - A cooldown timer prevents log flooding when the system stays blocked for longer periods.
19
+
20
+ ## Configuration
21
+
22
+ | Option | Description |
23
+ |--------|-------------|
24
+ | **Threshold (ms)** | Maximum acceptable event loop delay. Samples above this value count as "blocking". Default: `120 ms`. |
25
+ | **Sample interval (ms)** | How often to collect a measurement. Smaller values react faster but use slightly more CPU. Default: `1000 ms`. |
26
+ | **Consecutive hits** | Number of back-to-back samples that must exceed the threshold before an alert fires. Helps filter out one-off spikes. Default: `1`. |
27
+ | **Cooldown (ms)** | Minimum time between alerts so your logs do not get spammed while a problem persists. Default: `30,000 ms`. |
28
+ | **Show live delay metrics** | When enabled (default) the node's status displays the latest average and max delay so you can watch it in real time. |
29
+
30
+ The node has no inputs or outputs and can sit anywhere in your flow.
31
+
32
+ > The watchdog internally samples `monitorEventLoopDelay` with a medium (20 ms) resolution, which provides enough fidelity for alerts while keeping CPU overhead negligible.
33
+
34
+ Alerts are always emitted with `node.warn(...)` so they appear in the standard Node-RED log without additional configuration.
35
+
36
+ ## Interpreting the Status
37
+
38
+ - **Green dot** — Event loop delay is within the safe range.
39
+ - **Yellow ring** — Recent samples exceeded the threshold but not enough to trigger an alert yet.
40
+ - **Red dot** — Blocking detected. Check the runtime log for details about the max/avg delay.
41
+
42
+ ## Tips
43
+
44
+ - Run multiple watchdogs with different thresholds (for example *warn at 120 ms*, *error at 500 ms*) if you want layered alerting.
45
+ - Pair the node with system level monitoring (CPU, memory) to quickly confirm whether the blocking originated from Node-RED or external processes.
46
+ - Because the watchdog is passive and does not emit messages, it is safe to leave it deployed permanently even in large workspaces.
package/install.sh ADDED
@@ -0,0 +1,144 @@
1
+ #!/bin/bash
2
+
3
+ #=============================================================================
4
+ # Node-RED Rosepetal Image Tools - Universal Installation Script (Corrected)
5
+ #=============================================================================
6
+ # Installs system dependencies and builds the package for Node-RED.
7
+ # Supports Debian/Ubuntu, Fedora/CentOS/RHEL, Arch Linux, and macOS.
8
+ #
9
+ # Usage: ./install.sh
10
+ #=============================================================================
11
+
12
+ set -e # Exit on any error
13
+
14
+ # --- Configuration & Helpers ---
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ RED='\033[0;31m'
17
+ GREEN='\033[0;32m'
18
+ BLUE='\033[0;34m'
19
+ NC='\033[0m'
20
+
21
+ print_step() { echo -e "\n${BLUE}▶ $1${NC}"; }
22
+ print_success() { echo -e "${GREEN}✔ $1${NC}"; }
23
+ print_error() { echo -e "${RED}✖ $1${NC}" >&2; }
24
+ print_info() { echo " $1"; }
25
+
26
+ # --- System & Dependency Checks ---
27
+
28
+ check_command() {
29
+ command -v "$1" >/dev/null 2>&1
30
+ }
31
+
32
+ detect_os_and_pm() {
33
+ print_step "Detecting Operating System and Package Manager..."
34
+ OS=$(uname -s)
35
+ case "$OS" in
36
+ Linux*)
37
+ if check_command apt; then PM="apt"; OS_NAME="Debian/Ubuntu"
38
+ elif check_command dnf; then PM="dnf"; OS_NAME="Fedora/CentOS"
39
+ elif check_command yum; then PM="yum"; OS_NAME="CentOS/RHEL"
40
+ elif check_command pacman; then PM="pacman"; OS_NAME="Arch Linux"
41
+ else print_error "Unsupported Linux distribution." && exit 1; fi
42
+ ;;
43
+ Darwin*)
44
+ if ! check_command brew; then
45
+ print_error "Homebrew not found. Please install it from https://brew.sh"
46
+ exit 1
47
+ fi
48
+ PM="brew"; OS_NAME="macOS"
49
+ ;;
50
+ *)
51
+ print_error "Unsupported Operating System: $OS" && exit 1
52
+ ;;
53
+ esac
54
+ print_success "Detected $OS_NAME (using $PM)"
55
+ }
56
+
57
+ install_dependencies() {
58
+ print_step "Checking and installing system dependencies..."
59
+
60
+ # List of required packages per package manager
61
+ declare -A deps
62
+ deps[apt]="build-essential cmake pkg-config python3-dev libopencv-dev"
63
+ deps[dnf]="gcc-c++ cmake pkgconfig python3-devel opencv-devel"
64
+ deps[yum]="gcc-c++ cmake pkgconfig python3-devel opencv-devel"
65
+ deps[pacman]="base-devel cmake pkgconf python opencv"
66
+ deps[brew]="cmake pkg-config opencv"
67
+
68
+ if ! pkg-config --exists opencv4; then
69
+ print_info "OpenCV 4 not found, attempting to install..."
70
+ sudo -v # Refresh sudo timestamp
71
+ case "$PM" in
72
+ apt) sudo apt-get update && sudo apt-get install -y ${deps[apt]} ;;
73
+ dnf) sudo dnf install -y ${deps[dnf]} ;;
74
+ yum) sudo yum install -y ${deps[yum]} ;;
75
+ pacman) sudo pacman -S --noconfirm ${deps[pacman]} ;;
76
+ brew) brew install ${deps[brew]} ;;
77
+ esac
78
+ print_success "System dependencies installed."
79
+ else
80
+ print_success "All system dependencies are already satisfied."
81
+ fi
82
+ }
83
+
84
+ # --- Main Logic ---
85
+
86
+ main() {
87
+ echo "================================================="
88
+ echo " Node-RED Rosepetal Image Tools Installer"
89
+ echo "================================================="
90
+
91
+ if ! check_command node || ! check_command npm; then
92
+ print_error "Node.js and npm are required. Please install them first."
93
+ exit 1
94
+ fi
95
+ print_info "Node.js version: $(node --version)"
96
+ print_info "npm version: $(npm --version)"
97
+
98
+ detect_os_and_pm
99
+ install_dependencies
100
+
101
+ print_step "Building the C++ image engine..."
102
+ cd "$SCRIPT_DIR/rosepetal-image-engine"
103
+ if npm install; then
104
+ print_success "C++ engine dependencies installed and built successfully."
105
+ else
106
+ print_error "Failed to build the C++ engine."
107
+ exit 1
108
+ fi
109
+
110
+ print_step "Installing the Node-RED package..."
111
+ cd "$SCRIPT_DIR/node-red-contrib-image-tools"
112
+ if npm install; then
113
+ print_success "Node-RED package installed successfully."
114
+ else
115
+ print_error "Failed to install the Node-RED package."
116
+ exit 1
117
+ fi
118
+
119
+ echo "================================================="
120
+ print_success "Build complete!"
121
+ echo "================================================="
122
+
123
+ # --- Interactive Node-RED Installation ---
124
+ NODE_RED_DIR="$HOME/.node-red"
125
+ if [ -d "$NODE_RED_DIR" ]; then
126
+ print_step "Optional: Install into your Node-RED instance"
127
+ read -p "Do you want to install this package into '$NODE_RED_DIR'? (y/N) " -n 1 -r
128
+ echo
129
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
130
+ print_info "Installing into Node-RED..."
131
+ (cd "$NODE_RED_DIR" && npm install "$SCRIPT_DIR/node-red-contrib-image-tools")
132
+ print_success "Successfully installed in Node-RED."
133
+ print_info "Please restart your Node-RED instance to see the new nodes."
134
+ else
135
+ print_info "Skipping automatic installation."
136
+ print_info "You can install it later by running this command:"
137
+ print_info " cd ~/.node-red && npm install $SCRIPT_DIR/node-red-contrib-image-tools"
138
+ fi
139
+ fi
140
+ }
141
+
142
+ # --- Script Execution ---
143
+ trap 'print_error "Installation interrupted."; exit 1' INT TERM
144
+ main