Add Image
Adds an image to a Google Slides presentation.
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 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
- Presentation Id - The ID of the Google Slides presentation where the image will be added.
- Image Object Id - A unique identifier for the image object in the presentation.
- Image Url - The URL of the image to be inserted into the slide.
- Slide Page Index - The zero-based index of the slide where the image will be placed.
Options
- Height - The height of the image in points (PT). This defines how tall the image will be on the slide.
- Width - The width of the image in points (PT). This value determines how wide the image will appear on the slide.
- Translate X - The horizontal position where the image will be placed on the slide. A higher value moves the image further to the right. The default slide width is 960.0. Example center calculation: (960.0 - imageWidth) / 2.
- Translate Y - The vertical position of the image on the slide. Increasing this value moves the image lower down on the slide. The default slide height is 540.0. Example center calculation: (540.0 - imageHeight) / 2.
- Scale X - The horizontal scaling factor for the image. A value of 1.0 means the image's width is not altered.
- Scale Y - The vertical scaling factor. A value of 1.0 keeps the original height.
How It Works
The Add Image node integrates with Google Slides to insert an image into a specific slide of a presentation. When executed, the node:
- Validates the provided inputs (Presentation Id, Image Object Id, Image Url, Slide Page Index)
- Connects to the specified Google Slides presentation
- Retrieves the target slide based on the Slide Page Index
- Creates an image element with the specified properties (size, position, scaling)
- Inserts the image from the provided URL into the target slide
Requirements
- A valid Google Slides presentation ID
- Valid Google Slides API credentials
- A publicly accessible image URL
- Valid Google Slides permissions to modify the presentation
- A unique Image Object Id for the image element
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Presentation Id
- Empty or invalid Image Object Id
- Empty or invalid Image Url
- Invalid Slide Page Index (must be greater than or equal to zero)
- Invalid Translate X or Translate Y values (must be greater than or equal to zero)
- Invalid Scale X or Scale Y values (must be greater than zero)
- Invalid Height or Width values (must be greater than zero)
- Google Slides service errors
- Insufficient permissions to modify the presentation
Usage Notes
- The Presentation Id can be found in the URL of the Google Slides presentation
- The Image Url must be publicly accessible (not behind authentication)
- The Slide Page Index is zero-based, so the first slide is index 0, second is index 1, etc.
- The Image Object Id must be unique within the presentation
- For positioning the image at the center of the slide, calculate the appropriate Translate X and Translate Y values
- The default slide dimensions are 960.0 (width) by 540.0 (height) points
- Supported image formats include JPG, PNG, GIF, and other web-friendly formats
- The image will be added to the specified slide at the specified position and size
Examples
Example 1: Add Image to First Slide
Add a logo image to the top-left corner of the first slide:
Presentation Id: "1ABC..."
Image Object Id: "logo_001"
Image Url: "https://example.com/logo.png"
Slide Page Index: 0
Width: 150.0
Height: 50.0
Translate X: 20.0
Translate Y: 20.0
Scale X: 1.0
Scale Y: 1.0
Example 2: Center Image on Slide
Add an image centered on the slide:
// Calculate center position
const slideWidth = 960.0;
const slideHeight = 540.0;
const imageWidth = 400.0;
const imageHeight = 300.0;
msg.translateX = (slideWidth - imageWidth) / 2; // 280.0
msg.translateY = (slideHeight - imageHeight) / 2; // 120.0
// Then use Add Image node:
// Translate X: 280.0
// Translate Y: 120.0
// Width: 400.0
// Height: 300.0
Example 3: Add Multiple Images to Slide
Add several images to different positions on the same slide:
const images = [
{ id: "chart1", url: "https://example.com/chart1.png", x: 50, y: 100, w: 400, h: 300 },
{ id: "chart2", url: "https://example.com/chart2.png", x: 500, y: 100, w: 400, h: 300 },
{ id: "logo", url: "https://example.com/logo.png", x: 20, y: 20, w: 100, h: 40 }
];
for (const img of images) {
msg.imageObjectId = img.id;
msg.imageUrl = img.url;
msg.translateX = img.x;
msg.translateY = img.y;
msg.width = img.w;
msg.height = img.h;
// Use Add Image node here
}
Example 4: Add Scaled Image
Add an image with custom scaling:
Presentation Id: "1ABC..."
Image Object Id: "scaled_image_001"
Image Url: "https://example.com/photo.jpg"
Slide Page Index: 2
Width: 200.0
Height: 150.0
Translate X: 100.0
Translate Y: 100.0
Scale X: 1.5 // 150% width
Scale Y: 1.5 // 150% height
Understanding Positioning and Sizing
Coordinate System
- Origin (0,0) is at the top-left corner of the slide
- X increases to the right
- Y increases downward
- Units are in points (PT)
- Default slide size: 960 x 540 points
Size Parameters
- Width & Height: Base dimensions of the image in points
- Scale X & Scale Y: Multipliers applied to Width and Height
- 1.0 = original size
- 0.5 = half size
- 2.0 = double size
- Final width = Width × Scale X
- Final height = Height × Scale Y
Position Parameters
- Translate X: Horizontal position from left edge
- Translate Y: Vertical position from top edge
Tips for Effective Use
- Unique IDs: Generate unique Image Object IDs using timestamps or UUIDs to avoid conflicts
- Center Calculation: Use the formula
(slideSize - imageSize) / 2for centering - Aspect Ratios: Maintain aspect ratio by using same value for Scale X and Scale Y
- Layout Planning: Sketch slide layouts before coding positions
- Responsive Sizing: Calculate positions based on slide dimensions for flexibility
- Image Optimization: Compress images before uploading for faster processing
- URL Testing: Verify image URLs are accessible before running automation
Common Use Cases
Use Case 1: Add QR Code to Presentation
Add a QR code to each slide for tracking or linking:
// Generate QR code and upload to cloud storage
const qrCodeUrl = await generateQRCode(msg.presentationUrl);
// Add to bottom-right corner of each slide
const slideCount = msg.presentation.slides.length;
for (let i = 0; i < slideCount; i++) {
msg.imageObjectId = `qr_code_${i}`;
msg.imageUrl = qrCodeUrl;
msg.slideIndex = i;
msg.translateX = 820.0; // 960 - 140
msg.translateY = 480.0; // 540 - 60
msg.width = 120.0;
msg.height = 60.0;
// Use Add Image node
}
Use Case 2: Add Data Visualization Charts
Add dynamically generated chart images:
// Generate charts from data
const salesChart = await generateChartImage(msg.salesData);
const revenueChart = await generateChartImage(msg.revenueData);
// Upload and get URLs
const salesChartUrl = await uploadToStorage(salesChart);
const revenueChartUrl = await uploadToStorage(revenueChart);
// Add to specific slides
msg.imageObjectId = "sales_chart_001";
msg.imageUrl = salesChartUrl;
msg.slideIndex = 2;
msg.translateX = 50.0;
msg.translateY = 100.0;
msg.width = 850.0;
msg.height = 400.0;
// Add Image node for sales chart
// Repeat for revenue chart on next slide
Use Case 3: Add Company Watermark
Add a watermark to all slides:
const watermarkUrl = "https://example.com/watermark.png";
const slideCount = msg.presentation.slides.length;
for (let i = 0; i < slideCount; i++) {
msg.imageObjectId = `watermark_${i}`;
msg.imageUrl = watermarkUrl;
msg.slideIndex = i;
// Bottom center position
msg.translateX = 380.0;
msg.translateY = 480.0;
msg.width = 200.0;
msg.height = 40.0;
msg.scaleX = 0.7; // Subtle watermark
msg.scaleY = 0.7;
// Use Add Image node
}
Use Case 4: Create Image Grid Layout
Create a grid of product images on a slide:
const products = [
"https://example.com/p1.jpg",
"https://example.com/p2.jpg",
"https://example.com/p3.jpg",
"https://example.com/p4.jpg"
];
const gridConfig = {
columns: 2,
rows: 2,
imageWidth: 400,
imageHeight: 220,
startX: 80,
startY: 80,
spacingX: 40,
spacingY: 40
};
products.forEach((url, index) => {
const col = index % gridConfig.columns;
const row = Math.floor(index / gridConfig.columns);
msg.imageObjectId = `product_${index}`;
msg.imageUrl = url;
msg.slideIndex = 0;
msg.translateX = gridConfig.startX + (col * (gridConfig.imageWidth + gridConfig.spacingX));
msg.translateY = gridConfig.startY + (row * (gridConfig.imageHeight + gridConfig.spacingY));
msg.width = gridConfig.imageWidth;
msg.height = gridConfig.imageHeight;
// Use Add Image node
});
Use Case 5: Add Screenshots from Browser Automation
Combine browser automation with slide creation:
// After browser automation captures screenshots
const screenshots = msg.capturedScreenshots; // Array of uploaded URLs
screenshots.forEach((screenshotUrl, index) => {
msg.imageObjectId = `screenshot_${Date.now()}_${index}`;
msg.imageUrl = screenshotUrl;
msg.slideIndex = index + 1; // One screenshot per slide
// Center the screenshot
msg.translateX = 80.0;
msg.translateY = 70.0;
msg.width = 800.0;
msg.height = 400.0;
// Use Add Image node
});
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "Presentation ID cannot be empty" | No ID provided or ID is "_" | Ensure valid Presentation Id is provided |
| "Image Object ID cannot be empty" | No object ID provided | Provide unique object ID for the image |
| "Image URL cannot be empty" | No URL provided | Ensure valid publicly accessible image URL is provided |
| "Slide Page Index must be 0 or greater" | Negative index provided | Use zero-based index starting from 0 |
| "Translate X/Y must be 0 or greater" | Negative position values | Ensure position values are 0 or positive |
| "Scale X/Y must be > 0" | Zero or negative scale | Provide positive scale values (typically 0.1 to 5.0) |
| "Height/Width must be > 0" | Zero or negative dimensions | Provide positive width and height values |
| Duplicate object ID | Object ID already exists | Ensure each image has unique object ID |
| Image not appearing | URL not accessible | Test URL in browser; ensure public access |
| Image position off-slide | Coordinates exceed slide bounds | Verify position and size fit within 960x540 bounds |
Best Practices
- ID Generation: Use descriptive IDs with timestamps:
chart_sales_${Date.now()} - Bounds Checking: Ensure image position + size doesn't exceed slide dimensions
- Aspect Ratio: Calculate height from width (or vice versa) to maintain aspect ratio
- Batch Operations: When adding multiple images, collect all data first then process
- Error Handling: Wrap in try-catch for scenarios where images might not load
- Performance: For large batches, consider adding delays between operations
- Testing: Test with one image before processing large batches
- Documentation: Keep track of which Image Object IDs are used in each presentation