Skip to main content

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.
info

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:

  1. Validates the file descriptor and image path
  2. Checks that the image file exists and is accessible
  3. Validates width, height, and spacing values
  4. Retrieves the document from memory
  5. Adds the image with specified dimensions (or auto-size if width/height is 0)
  6. Applies the selected alignment to the paragraph containing the image
  7. 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

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

  1. Aspect Ratio: Set only width OR height (not both) to maintain aspect ratio
  2. 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)
  3. File Paths: Use absolute paths for reliability
  4. Image Quality: Use high-resolution images (300 DPI) for print documents
  5. File Size: Optimize images before adding to keep document size manageable
  6. Spacing: Add space after images to separate them from following content
  7. 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)CoverageBest Use
1.0 - 2.0SmallIcons, logos, thumbnails
2.5 - 4.0MediumCharts, diagrams
4.5 - 6.0LargeFeatured images, wide charts
6.5Full widthFull-page images

Common Image Dimensions

Image TypeWidthHeightNotes
Logo2.00 (auto)Maintains aspect ratio
Business Card3.52.0Standard card size
Chart5.03.5Good for data visualization
Screenshot6.00 (auto)Full-width documentation
Photo4.03.0Standard photo ratio

Supported Image Formats

FormatExtensionBest ForNotes
PNG.pngLogos, graphics with transparencyLossless compression
JPEG.jpg, .jpegPhotographs, complex imagesLossy compression, smaller files
GIF.gifSimple graphics, animationsLimited colors
BMP.bmpWindows graphicsLarge file sizes

Common Errors and Solutions

ErrorCauseSolution
"File descriptor cannot be empty"No file descriptor providedEnsure Create Word or Open Word node runs first
"Image path cannot be empty"No image path providedProvide a valid file path to the image
"Image file not found at [path]"Image doesn't existVerify the image file exists at the specified path
"Document not found"Invalid file descriptorCheck file descriptor matches Create/Open Word output
"Width and height must be greater than or equal to zero"Negative dimensionsUse 0 or positive values for width and height
"Space after must be equal or greater than zero"Negative spacingUse 0 or positive values
"Failed to add image"Corrupted image or unsupported formatVerify image is valid and in supported format

Auto-Sizing Behavior

WidthHeightResult
00Original image size (may be very large)
X0Width = X inches, height maintains aspect ratio
0YHeight = Y inches, width maintains aspect ratio
XYExact 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

  1. Image Not Appearing: Check file path is correct and file exists
  2. Image Too Large/Small: Adjust width/height values, use 0 for auto
  3. Poor Quality: Use higher resolution source images
  4. Document Too Large: Compress or resize images before adding
  5. Alignment Issues: Verify alignment setting matches desired layout