Overlay image grid to another image

I would like to make an 3-5 horizontal image grid, scale it down and combine on top of another image. Image a thumbnail that shows small color variants. Can this be achieved?

This is how it should look like afterwards:

––––––––––––––––––
|                |
|                |
|                |
|   [1][2][3][4] |
|                |
––––––––––––––––––

Thanks for your help!

Hi Frank,

Does the attached image show what you had in mind?

Almost, I would do like something like this:

Finally found the upload-button :wink:

This would be a basic question, if it’s possible to use 2 different sources for images to combine: one for the main image and one for the row images and then combine both. could not find a way to do this…

There’s no way to dynamically change the overlay image on the fly, so only one of the source images would be changing.

With what you’re doing, both the background and the little grid in the bottom right are changing for each image?

Did it by hand in photoshop, but would love to find a way to automate it… So what if all of them would be source images and the first would be background and the other ones combine to a image grid that gets overlayed? That was my thought… but seams to be too complex.

Frank, you could try using a Shell Script Node — for example, with the script below. See the attached output it produces.

#!/bin/bash
# ImageMagick v7 script that creates color variant thumbnails on your images

INPUT="$1"

# Find magick command
MAGICK=""
PATHS=("/opt/homebrew/bin" "/usr/local/bin" "/opt/local/bin")

for path in "${PATHS[@]}"; do
    if [ -f "$path/magick" ]; then
        MAGICK="$path/magick"
        break
    fi
done

if [ -z "$MAGICK" ]; then
    if command -v magick &> /dev/null; then
        MAGICK=$(command -v magick)
    else
        echo "ERROR: ImageMagick not found" >&2
        exit 1
    fi
fi

# Get dimensions
WIDTH=$("$MAGICK" identify -format "%w" "$INPUT")
HEIGHT=$("$MAGICK" identify -format "%h" "$INPUT")

# Color overlays (customize these!)
COLORS=("#C87E50" "#50A090" "#E0B040" "#5090C8")

TMPDIR=$(mktemp -d)

# Create color variants
for i in {0..3}; do
    "$MAGICK" "$INPUT" \
        -resize 150x150^ -gravity center -extent 150x150 \
        \( +clone -fill "${COLORS[$i]}" -colorize 50% \) \
        -compose multiply -composite \
        "$TMPDIR/variant_$i.jpg"
done

# Create grid
"$MAGICK" montage "$TMPDIR"/variant_{0..3}.jpg \
        -tile 4x1 -geometry 150x150+8+0 \
        -background none \
        "$TMPDIR/grid.png"

# Calculate positions
GRID_WIDTH=$((WIDTH / 2))
X_POS=$((WIDTH * 45 / 100))
Y_POS=$((HEIGHT - (HEIGHT * 10 / 100) - 150))

# Composite onto original
"$MAGICK" "$INPUT" \
  \( "$TMPDIR/grid.png" -resize "${GRID_WIDTH}x" \) \
  -geometry "+${X_POS}+${Y_POS}" \
  -composite \
  "$TMPDIR/output.jpg"

# Replace original file
cp "$TMPDIR/output.jpg" "$INPUT"

# Cleanup
rm -rf "$TMPDIR"