|
| 1 | +#!/bin/bash |
| 2 | +# Generate Open Graph images for social media sharing |
| 3 | +# Uses the actual app icon for a professional, recognizable look |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 8 | +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" |
| 9 | +STATIC_DIR="$PROJECT_ROOT/static" |
| 10 | +ICON="$STATIC_DIR/icon.png" |
| 11 | + |
| 12 | +# Verify icon exists |
| 13 | +if [ ! -f "$ICON" ]; then |
| 14 | + echo "Error: icon.png not found at $ICON" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +cd "$STATIC_DIR" |
| 19 | + |
| 20 | +# Colors (WhatsApp theme) |
| 21 | +BG_DARK="#075e54" # WhatsApp dark green (header/dark mode) |
| 22 | +BG_TEAL="#128C7E" # WhatsApp teal |
| 23 | + |
| 24 | +echo "Generating Open Graph images with app icon..." |
| 25 | + |
| 26 | +# ============================================================================= |
| 27 | +# Main OG image (1200x630) - Facebook, LinkedIn, Discord, general |
| 28 | +# Layout: Gradient background, icon on left, text on right |
| 29 | +# ============================================================================= |
| 30 | +magick -size 1200x630 \ |
| 31 | + -define gradient:direction=east \ |
| 32 | + "gradient:${BG_DARK}-${BG_TEAL}" \ |
| 33 | + \( "$ICON" -resize 280x280 \ |
| 34 | + \( +clone -background black -shadow 60x20+0+10 \) \ |
| 35 | + +swap -background none -layers merge +repage \ |
| 36 | + \) -gravity west -geometry +100+0 -composite \ |
| 37 | + -fill white \ |
| 38 | + -font "Helvetica-Bold" -pointsize 56 \ |
| 39 | + -gravity west -annotate +460-30 "WhatsApp" \ |
| 40 | + -annotate +460+40 "Backup Reader" \ |
| 41 | + -font "Helvetica" -pointsize 26 \ |
| 42 | + -fill "rgba(255,255,255,0.85)" \ |
| 43 | + -annotate +460+110 "Read your chat exports offline • Private & secure" \ |
| 44 | + og-image.png |
| 45 | + |
| 46 | +echo "✅ Created og-image.png (1200x630)" |
| 47 | + |
| 48 | +# ============================================================================= |
| 49 | +# WhatsApp square image (800x800) - Avoids cropping on WhatsApp |
| 50 | +# Layout: Icon centered on top, text below |
| 51 | +# ============================================================================= |
| 52 | +magick -size 800x800 \ |
| 53 | + -define gradient:direction=south \ |
| 54 | + "gradient:${BG_DARK}-${BG_TEAL}" \ |
| 55 | + \( "$ICON" -resize 260x260 \ |
| 56 | + \( +clone -background black -shadow 60x20+0+10 \) \ |
| 57 | + +swap -background none -layers merge +repage \ |
| 58 | + \) -gravity center -geometry +0-100 -composite \ |
| 59 | + -fill white \ |
| 60 | + -font "Helvetica-Bold" -pointsize 44 \ |
| 61 | + -gravity center -annotate +0+110 "WhatsApp" \ |
| 62 | + -annotate +0+165 "Backup Reader" \ |
| 63 | + -font "Helvetica" -pointsize 22 \ |
| 64 | + -fill "rgba(255,255,255,0.85)" \ |
| 65 | + -annotate +0+230 "Read your chats offline • Private & secure" \ |
| 66 | + og-image-square.png |
| 67 | + |
| 68 | +echo "✅ Created og-image-square.png (800x800)" |
| 69 | + |
| 70 | +# ============================================================================= |
| 71 | +# Twitter/X image (copy of main, same dimensions work for Twitter cards) |
| 72 | +# ============================================================================= |
| 73 | +cp og-image.png og-image-twitter.png |
| 74 | +echo "✅ Created og-image-twitter.png (copy of og-image.png)" |
| 75 | + |
| 76 | +# Show file sizes |
| 77 | +echo "" |
| 78 | +echo "📊 Generated images:" |
| 79 | +ls -lh og-image*.png |
| 80 | + |
| 81 | +echo "" |
| 82 | +echo "🎯 Usage:" |
| 83 | +echo " - og-image.png (1200x630): Facebook, LinkedIn, Discord" |
| 84 | +echo " - og-image-square.png (800x800): WhatsApp (avoids cropping)" |
| 85 | +echo "" |
| 86 | +echo "💡 Test at: https://developers.facebook.com/tools/debug/" |
0 commit comments