how to check where the uploaded images already exist in the system

Dani AI

Generated

asked for "look alike" detection rather than name matches. and were right that filename/size and byte-by-byte comparisons catch exact duplicates, but those approaches miss resized, reencoded, or lightly edited copies. For practical, reliable results use a two-stage approach: fast exact-match filtering, then a perceptual similarity check for near-duplicates.

Stage 1 (fast exact): store file size and a cryptographic content hash (MD5/SHA256) and reject uploads that match exactly.
Stage 2 (near-duplicate): compute a perceptual fingerprint (pHash / dHash / aHash) or image descriptor (ORB/BRISK) and compare against stored fingerprints. Perceptual hashes are compact (commonly 64 bits), fast to compare (Hamming distance), and robust to format/size changes. For ASP.NET you can use ImageMagick via Magick.NET, OpenCV via OpenCvSharp/EmguCV, or ImageSharp + a pHash implementation to generate fingerprints and basic histograms. Store hashes in the database (as integers/binaries) and use indexed prefix buckets or LSH-style bucketing to limit comparisons at upload time.

Practical tips and tradeoffs: normalize images first (resize to a canonical size, strip metadata, optionally convert to grayscale). Tune the Hamming-distance threshold on a representative sample; start conservatively and adjust for your false-positive/false-negative tolerance. For region changes, heavy cropping, or watermarks, feature matching (ORB) with RANSAC gives better results but costs more CPU. Precompute fingerprints at upload and run batch scans asynchronously to avoid blocking users.

If you need a percentage score (as wanted), convert Hamming distance to a simple similarity percent, for example:

similarityPercent = 100 * (1 - hammingDistance / (float)hashLength)

Experiment with different hash types and thresholds on your data; that empirical tuning is the key to making "look alike" detection work well in the real world.

Recommended Answers

All 4 Replies

Huh? Do you want to check to see if someone uploaded the same image twice? You could check the filename and filesize...other than that I'm not sure what you're asking.

hello,
while uploading a image i have to check whether the same image already exist.
i have to compare the images irrespective of image name.i have to check whether the image look alike

That is complicated. I would start by narrowing down the list in your database by file size.... and then looping through the list of files with the same size, and comparing those to what you have. I imagine this process to take a long time, but the next step, would be to read in the first image file, byte by byte (maybe into a byte array, or something), and then compare the respective bytes of the uploaded file, with the bytes in the current file of the same size... if all the bytes are the same, the image is obviously the same.

A possibility to speeding up this process, would be to read a couple of bytes from different locations within the file, and compare those couple of bytes to the corresponding bytes. This isn't easy.... but it can most certainly be done.

hello,
while uploading a image i have to check whether the same image already exist.
i have to compare the images irrespective of image name.i have to check whether the image look alike

Hi Deepa,

I am devloping Image Comparison Application in ASP.net which compares images irrespective of it's format,size and gives result in Percentage Format!!
I want to know whether it's possible to comapre 2 images using asp.net irrespective of their format and result should be in percenatge format like 80%-90% like that...
And the criterias for comparison are not "image size,pixel by pixel comparison and height,width". But they are other than this!! Can anyone suggest criterias for such comparison?....

Are you successfull in finding same images irrespective of their format,size in the problem that you have posted?...
Example:
**say there is a yellow rose picture and another with red rose picture
**then similarity is 99%
**irrespective of the height and width of the images
Can anyone please help me in this matter.It would be really appreciated if anyone gives some good links.If you can provide with some sample code it would be really appreciated. It's very much like a research topic.Most of stuff i got was research one & not related to programming pt. of view..
Hoping +ve Reply!!

thanks hrishi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.