Replies: 5 comments 3 replies
-
|
@ridzria you might be better off doing something like a md5 checksum comparison or something along those lines |
Beta Was this translation helpful? Give feedback.
-
|
@ridzria, the function Please note that the original generates 64-bit hashes. My function generates 512-bit hashes. Which means I've done something different in my implementation but I haven't taken the time to dive deeper into it. Please do let me know if Usagedef kinda_same?(image_1, image_2) do
Image.dhash(image_1) == Image.dhash(image_2)
end |
Beta Was this translation helpful? Give feedback.
-
|
That means let's say I have an image url which I wanted to compare. There are 2 scenarios.
Scenario 1: image_url_1 = "https://server/image1.jpg"
image_url_2= "https://server/image2.jpg"
def compare_image(image_url_1, image_url_2)
{
image_1 = get_image(image_url_1)
image_2 = get_image(image_url_2)
case Image.dhash(image_1) == Image.dhash(image_2) do
true ->
{:error, :duplicate_image}
false ->
{:ok, :safer_to_upload}
end
}
def get_image(url)
{
%HTTPoison.Response{body: image_data} = HTTPoison.get!(url)
{:ok, image_data} = Image.from_binary(image_data)
image_data
}Scenario 2: image_url_1 = "https://server/image1.jpg"
def compare_image_with_upload_image(image_url_1, upload_image_path)
{
image_1 = get_image(image_url_1)
image_2 = upload_image_path |> Base.encode64()
case Image.dhash(image_1) == Image.dhash(image_2) do
true ->
{:error, :duplicate_image}
false ->
{:ok, :safer_to_upload}
end
}Scenario 1: I have 2 urls of same image with different resolutions. When I compare I get |
Beta Was this translation helpful? Give feedback.
-
|
In your scenario 2 For scenario 1, perceptual hashes aren't perfect - but they don't really care about resolution. The first thing the hash does is to resize the image to an 8x8 size. You might find Something like: # See Image.hamming_distance/2
@similarity_threshold 10
def compare_image(image_url_1, image_url_2) do
image_1 = get_image(image_url_1)
image_2 = get_image(image_url_2)
if Image.hamming_distance(image_1, image_2) < @similarity_threshold do
{:ok, :safer_to_upload}
else
{:error, :duplicate_image}
end
end |
Beta Was this translation helpful? Give feedback.
-
|
Please note that I have just pushed a commit that returns the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Let’s say I have an image already uploaded and stored in the system.
When a user upload the same image for instance, is there a way to compare with existing list of images by the same user and see if it is duplicate indeed. If not then allow the user to upload otherwise throw an error.
Is there comparison of images for duplicate feature is available? If not this feature is awesome to have.
Beta Was this translation helpful? Give feedback.
All reactions