Find Images By Tags Introduction
This article explains how to find images by tags.
The API URL is: POST /imaging/ai/imageSearch/{searchContextId}/findByTags
Resource URI
Swagger UI lets you call Aspose.Imaging REST APIs directly from the browser. The description of the APIs and their parameters are also given there.
cURL Example
SDKs
Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project. Check out our GitHub repository for a complete list of Aspose.Imaging SDKs along with working examples, to get you started in no time.
SDK Examples
.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void FindSimilarImagesByTag()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string ImageToFindByTag = "ComparingImageSimilar75.jpg";
string ImagesPath = @"FindSimilar\";
string fileName = ImageToFindByTag;
FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName);
this.CreateImageFeatures(ImagesPath.TrimEnd('\\'), true, searchContextId);
string tagName = "ImageTag";
double? similarityThreshold = 60;
int? maxCount = 5;
string folder = null; // Path to input files
string storage = null; // We are using default Cloud Storage
this.ImagingApi.CreateImageTag(
new CreateImageTagRequest(inputImageStream, searchContextId, tagName, folder, storage));
var tags = JsonConvert.SerializeObject(new[] { tagName});
SearchResultsSet searchResultsSet = this.ImagingApi.FindImagesByTags(
new FindImagesByTagsRequest(tags, searchContextId, similarityThreshold, maxCount, storage: storage));
// Process search results
foreach (SearchResult searchResult in searchResultsSet.Results)
{
Console.WriteLine("ImageName: " + searchResult.ImageId +
", Similarity: " + searchResult.Similarity);
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
Java