🌘 Social Media Image Generator

This tool automatically generates dynamic cover images for blog articles and pages, and updates their metadata to reference those images for social network display.

🌘 Features

🌘 Installation

  1. Ensure you have ImageMagick installed for optimal image generation:

    # macOS
    brew install imagemagick
    
    # Ubuntu/Debian
    sudo apt-get install imagemagick
    
    # Windows
    # Download from: https://imagemagick.org/script/download.php
  2. Install dependencies:

    npm install

🌘 Usage

🌘 Generate Social Images

# Generate images for all blog articles and pages
npm run build:social-images

# Or run directly
node generate_social_images.js

🌘 Manual Processing

You can also import and use the generator in other scripts:

const SocialImageGenerator = require('./generate_social_images.js');

const generator = new SocialImageGenerator();
generator.run().catch(console.error);

🌘 Configuration

The generator can be configured by modifying the CONFIG object in generate_social_images.js:

const CONFIG = {
  sourceDirs: [
    'blogue/**/*.md',
    'pages/**/*.md'
  ],
  outputDir: 'static/images/social',
  imageWidth: 1200,
  imageHeight: 630,
  fontPath: 'static/fonts/FiraSans',
  defaultColors: {
    background: '#1a1a2e',
    text: '#ffffff',
    accent: '#f39c12'
  },
  processedMarker: 'social_image_generated'
};

🌘 Color Schemes

Different categories use different color themes:

You can customize these in the COLOR_SCHEMES object.

🌘 Output

🌘 Generated Images

Images are saved to static/static/images/social/ with filenames based on the source markdown file paths.

🌘 Updated Frontmatter

Each processed file gets its frontmatter updated with:

social_image: static/images/social/blogue-2025-2025-10-19-utilisation-de-grands-modeles-de-langage-localement-en-recherche.png
social_image_width: 1200
social_image_height: 630
social_image_alt: "Article Title - Social media cover image"
social_image_generated: true

🌘 Tracking File

A .processed.json file is created in the output directory to track processed files and avoid duplicate work.

🌘 Examples

🌘 Before Processing

---
title: Communauté DALIAS - Utilisation de grands modèles de langage localement en recherche
date: '2025-10-05'
categories:
  - collaborations
tags:
  - intelligence-artificielle
  - academique
  - python
  - ollama
  - transformers
  - dalias
  - communaute
  - sante
  - donnees
  - vie-privee
---

🌘 After Processing

---
title: Communauté DALIAS - Utilisation de grands modèles de langage localement en recherche
date: '2025-10-05'
categories:
  - collaborations
tags:
  - intelligence-artificielle
  - academique
  - python
  - ollama
  - transformers
  - dalias
  - communaute
  - sante
  - donnees
  - vie-privee
social_image: static/images/social/blogue-2025-2025-10-19-utilisation-de-grands-modeles-de-langage-localement-en-recherche.png
social_image_width: 1200
social_image_height: 630
social_image_alt: "Communauté DALIAS - Utilisation de grands modèles de langage localement en recherche - Social media cover image"
social_image_generated: true
---

🌘 Integration with Eleventy

The generated social image metadata can be used in your Eleventy templates:

🌘 Troubleshooting

🌘 ImageMagick Not Found

If ImageMagick is not installed, the generator will fall back to creating simple placeholder images. For best results, install ImageMagick.

🌘 Permission Errors

Ensure you have write permissions for:

🌘 Missing Dependencies

Run npm install to ensure all required dependencies are installed.

🌘 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

🌘 License

This project is licensed under the same terms as the main project.