Add Image
Adds an image to a Word document with customizable size and alignment.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- In File Descriptor - Unique identifier of the document to add image to. This comes from the Create Word or Open Word node. Default variable is
{{$message.word_fd}}. - Image Path - Path to the image file to add. Supports common formats: PNG, JPG, JPEG, GIF, BMP.
- Width (inches) - Image width in inches. Set to 0 for automatic width based on original image size or height.
- Height (inches) - Image height in inches. Set to 0 for automatic height based on original image size or width.
- Space After - Space after the image in points. Default is 0. Use values like 12, 18, or 24 to add spacing.
Options
- Alignment - Image alignment in the document:
- Left - Align image to the left margin
- Center - Center the image (default)
- Right - Align image to the right margin
How It Works
The Add Image node inserts an image into the Word document with specified dimensions and alignment. When executed, the node:
- Validates the file descriptor and image path
- Checks that the image file exists and is accessible
- Validates width, height, and spacing values
- Retrieves the document from memory
- Adds the image with specified dimensions (or auto-size if width/height is 0)
- Applies the selected alignment to the paragraph containing the image
- Adds spacing after the image if specified
Requirements
- Valid file descriptor from Create Word or Open Word node
- Valid path to an existing image file
- Supported image format (PNG, JPG, JPEG, GIF, BMP)
- Non-negative width, height, and space values
- Read permissions for the image file
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid file descriptor
- Document not found
- Empty image path
- Image file not found at the specified path
- Unsupported image format
- Negative width, height, or space after values
- Insufficient permissions to read the image file
Usage Examples
Example 1: Add Company Logo
Scenario: Add a centered company logo at the top of a document
// Set logo path
$local.logoPath = "/home/user/images/company_logo.png";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Image Path:
{{$local.logoPath}} - Width (inches):
2 - Height (inches):
0(auto) - Space After:
18 - Alignment:
Center
Result: Logo is 2 inches wide, height auto-adjusted, centered with spacing below.
Example 2: Add Chart Image
Scenario: Add a chart image with specific dimensions
// Path to generated chart
$local.chartPath = "/tmp/sales_chart.png";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Image Path:
{{$local.chartPath}} - Width (inches):
6 - Height (inches):
4 - Space After:
12 - Alignment:
Center
Result: Chart is 6x4 inches, centered with 12pt spacing after.
Example 3: Add Screenshot
Scenario: Add a screenshot aligned to the left
// Screenshot path
$local.screenshotPath = "/home/user/screenshots/screen_1.png";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Image Path:
{{$local.screenshotPath}} - Width (inches):
5 - Height (inches):
0(auto) - Space After:
6 - Alignment:
Left
Result: Screenshot is 5 inches wide, left-aligned with 6pt spacing.
Example 4: Add Multiple Images
Scenario: Add multiple product images in sequence
// Array of product images
$local.productImages = [
"/images/product1.jpg",
"/images/product2.jpg",
"/images/product3.jpg"
];
// Loop through images (use separate Add Image nodes or loop in flow)
Configuration for each:
- In File Descriptor:
{{$message.word_fd}} - Image Path: (each product image path)
- Width (inches):
3 - Height (inches):
3 - Space After:
12 - Alignment:
Center
Usage Notes
- Images are added at the end of the document
- Setting both width and height to 0 uses the original image dimensions
- Setting only width or only height maintains the aspect ratio
- Large images are automatically scaled to fit page width if no dimensions specified
- Supported image formats depend on the system's image processing libraries
- Multiple images can be added by using multiple Add Image nodes
Tips for Effective Use
- Aspect Ratio: Set only width OR height (not both) to maintain aspect ratio
- Standard Sizes:
- Logos: 1.5-2.5 inches wide
- Charts: 4-6 inches wide
- Full-width images: 6-6.5 inches (for standard 8.5" page with margins)
- File Paths: Use absolute paths for reliability
- Image Quality: Use high-resolution images (300 DPI) for print documents
- File Size: Optimize images before adding to keep document size manageable
- Spacing: Add space after images to separate them from following content
- Alignment Choice:
- Center: For logos, charts, featured images
- Left: For screenshots, inline images
- Right: For callout images, side elements
Best Practices
- Test Image Paths: Verify image files exist before running the automation
- Consistent Sizing: Use similar dimensions for related images
- Format Selection: Use PNG for logos, JPG for photographs
- Resolution Check: Ensure images are high quality but not excessively large
- Document Flow: Add images in logical positions relative to text
- Accessibility: Consider adding alt text using Word's built-in features
- Preview Documents: Always preview documents to verify image placement
Image Size Guidelines
Page Width Reference (8.5" x 11" page with 1" margins)
| Width (inches) | Coverage | Best Use |
|---|---|---|
| 1.0 - 2.0 | Small | Icons, logos, thumbnails |
| 2.5 - 4.0 | Medium | Charts, diagrams |
| 4.5 - 6.0 | Large | Featured images, wide charts |
| 6.5 | Full width | Full-page images |
Common Image Dimensions
| Image Type | Width | Height | Notes |
|---|---|---|---|
| Logo | 2.0 | 0 (auto) | Maintains aspect ratio |
| Business Card | 3.5 | 2.0 | Standard card size |
| Chart | 5.0 | 3.5 | Good for data visualization |
| Screenshot | 6.0 | 0 (auto) | Full-width documentation |
| Photo | 4.0 | 3.0 | Standard photo ratio |
Supported Image Formats
| Format | Extension | Best For | Notes |
|---|---|---|---|
| PNG | .png | Logos, graphics with transparency | Lossless compression |
| JPEG | .jpg, .jpeg | Photographs, complex images | Lossy compression, smaller files |
| GIF | .gif | Simple graphics, animations | Limited colors |
| BMP | .bmp | Windows graphics | Large file sizes |
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "File descriptor cannot be empty" | No file descriptor provided | Ensure Create Word or Open Word node runs first |
| "Image path cannot be empty" | No image path provided | Provide a valid file path to the image |
| "Image file not found at [path]" | Image doesn't exist | Verify the image file exists at the specified path |
| "Document not found" | Invalid file descriptor | Check file descriptor matches Create/Open Word output |
| "Width and height must be greater than or equal to zero" | Negative dimensions | Use 0 or positive values for width and height |
| "Space after must be equal or greater than zero" | Negative spacing | Use 0 or positive values |
| "Failed to add image" | Corrupted image or unsupported format | Verify image is valid and in supported format |
Auto-Sizing Behavior
| Width | Height | Result |
|---|---|---|
| 0 | 0 | Original image size (may be very large) |
| X | 0 | Width = X inches, height maintains aspect ratio |
| 0 | Y | Height = Y inches, width maintains aspect ratio |
| X | Y | Exact dimensions X by Y inches (may distort) |
Advanced Usage Patterns
Dynamic Image Paths
// Generate image path dynamically
$local.year = new Date().getFullYear();
$local.month = new Date().getMonth() + 1;
$local.chartPath = `/reports/charts/sales_${$local.year}_${$local.month}.png`;
Conditional Image Addition
// Add different images based on conditions
if ($local.reportType === "executive") {
$local.imagePath = "/images/executive_chart.png";
$local.imageWidth = 6;
} else {
$local.imagePath = "/images/standard_chart.png";
$local.imageWidth = 4;
}
Image with Caption
// Add image, then add caption using Add Text node
// 1. Add Image node
// - Image Path: "/images/product.png"
// - Width: 4, Height: 0, Space After: 0
// 2. Add Text node (immediately after)
// - Text: "Figure 1: Product Overview"
// - Font Size: 10
// - Space After: 12
Performance Considerations
- Large Images: Images over 5MB may slow down document creation
- Multiple Images: Adding many images increases processing time
- Resolution: Higher resolution = larger file size
- Optimization: Pre-optimize images for web/documents (72-150 DPI for screen, 300 DPI for print)
Troubleshooting Tips
- Image Not Appearing: Check file path is correct and file exists
- Image Too Large/Small: Adjust width/height values, use 0 for auto
- Poor Quality: Use higher resolution source images
- Document Too Large: Compress or resize images before adding
- Alignment Issues: Verify alignment setting matches desired layout