Image search in network

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Search MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-search -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-search/search-net-mcp:latest
Folders, licensing and more →

To run a reverse image search, use the SearchFirst method of the Searcher class. This method returns the first portion of results as a NetworkImageSearchResult object, which contains the images found in one shard.

To continue the search, the SearchNext method is used, returning the second and subsequent portions of results. Continue the search while the NetworkImageSearchToken property of the result is not null.

The search image object and search options object are the same as those used for single index searches. Images can be found only if image indexing was enabled when the documents were added.

Note
Since version 26.11, only the first 10 found images of a NetworkImageSearchResult can be retrieved in the evaluation mode: the GetFoundImage method throws LicenseRestrictionException for an image number of 10 or greater, and the ImageCount property returns the number of all found images. See Evaluation limitations and licensing.

The examples on this page use the master node of a running search network. The following code creates and starts the master node as described on the Search network deployment page; the slave nodes must be started beforehand.

C#

string basePath = @"c:\SearchNetwork\";
int basePort = 49100;

// Loading the search network configuration from a file
Configuration configuration = Configuration.Load(basePath + "Configuration.xml");

// Creating, configuring and starting the master node; the timeouts are specified in milliseconds
SearchNetworkNode node = SearchNetworkNode.CreateMasterNode(
    0,
    basePath + "Node0",
    new TcpSettings(basePort, 3000, 3000, 3000, 1000),
    new FileLogger(basePath + "Log.txt", 4.0),
    configuration);
node.ConfigureAllNodes();
node.Start();

The following code example, which continues the previous one, demonstrates performing a reverse image search on the search network.

C#

// Creating a search image from a file
SearchImage searchImage = SearchImage.Create(@"c:\MyDocuments\Image.png");
int hashDifferences = 8; // The maximum allowed difference between the image hashes

Console.WriteLine("First image search");

Searcher searcher = node.Searcher;
ImageSearchOptions options = new ImageSearchOptions();
options.HashDifferences = hashDifferences;
int total = 0;

NetworkImageSearchResult result = searcher.SearchFirst(searchImage, options);
Console.WriteLine("Images found (shard " + result.ShardIndex + "): " + result.ImageCount);
total += result.ImageCount;

while (result.NetworkImageSearchToken != null)
{
    Console.WriteLine();
    Console.WriteLine("Next image search");

    result = searcher.SearchNext(result.NetworkImageSearchToken);
    Console.WriteLine("Images found (shard " + result.ShardIndex + "): " + result.ImageCount);
    total += result.ImageCount;
}

Console.WriteLine();
Console.WriteLine("Total images found (diffs = " + hashDifferences + "): " + total);

More information about reverse image search can be found on the Reverse image search page.

More resources

GitHub examples

You may easily run the code from documentation articles and see the features in action in our GitHub examples:

Free online document search App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.