similar_images
Displays "related images" on your site. This module analyzes your image library to find visuals that look similar to one another, helping keep visitors engaged by suggesting relevant visual content without requiring manual tagging.
Features
The Similar Images module uses mathematical analysis to determine visually related content within your Drupal Media library. Instead of relying on manual tags, taxonomies, or external AI services, this module calculates a unique "visual fingerprint" (hash) for your images and stores it locally.
Key functionalities include:
- Automated Similarity Detection: Once set up, the system automatically finds images that look like other images based on color composition, structure, and shapes.
- Native Media Integration: It adds the necessary storage fields directly to Drupal core's standard Image Media type out-of-the-box.
- Bulk Processing via Drush: Includes a robust Drush command to generate visual hashes for all your existing historical images in one go.
- Views Integration: The primary way to display similar images is through Drupal Views. The module provides new Views arguments or filters allowing you to create blocks like "More images like this" on media/node pages.
- Multiple Algorithms: (Future potential depending on implementation) The module supports different comparison algorithms to fine-tune how strictly "similarity" is defined.
When to use this module: Use this when you have a large library of photographic content (e.g., a portfolio, news site, or e-commerce store) and want to encourage users to keep browsing by showing visually similar items automatically, without the editorial burden of manually curating "related content" lists.
Post-Installation
After installing the module normally, there are two critical steps to make it functional:
Generate Hashes (Required): The module needs to analyze your existing images. Run: drush similar-images:generate-hashes. This command will process your image files and populate the newly created hash field on your Media entities. This task can be heavy -- consider moving to cron with queue workers or at minimum batch processing.
Create a View: Go to Structure > Views and create a new View (usually a Block view listing Media items). You will need to add a "Contextual Filter" (Argument) provided by this module, usually passing the ID of the currently viewed image. The View will then use the stored hashes to calculate and display the closest visual matches.
// @todo add info about
Additional Requirements
Drupal Core Media: This module relies on the core Media system.
Recommended modules/libraries
Similar projects
Most similar image projects in the Drupal ecosystem rely on external, third-party APIs (like Google Vision or AWS Rekognition) which often incur costs or require sending your data off-server.
This module differentiates itself by doing everything locally and natively. It uses PHP-based hashing algorithms on your own server, keeping your data private and avoiding external subscription fees.