In my web page a user will upload an image then after submit it should be compared with all images in a directory and output similar images. I did this with md5 but it will output only exact images and I know the reason but I don't know how to loop all images in my directory with the inputted image using RGB comparisons... Can somebody please help me. Here is my current code:
<?php
if(isset($_POST['submit'])){
$filepath=pathinfo($_FILES['file']['name']) ;
$extension=$filepath['extension'];
$iname= date('H-i-s').'.'.$extension;
$path='upload/'.$iname;
if(move_uploaded_file($_FILES['file']['tmp_name'],$path)){
$img=$path;
echo $img;
$f=md5(file_get_contents($img));
$images=glob("img/*");
foreach($images as $image){
if($f==md5(file_get_contents($image))){
echo "<img height='70px' width='70px' src='".$image."'/>";
}
}
}
}
?>
And my html code
<html>
<body>
<form method=post enctype="multipart/form-data">
<input type=file name=file><br><input type=submit name=submit value=submit>
</form>
</body>
</html>
source https://stackoverflow.com/questions/72720327/output-similar-images-in-a-directory-after-comparison-with-the-inputed-image-in
No comments:
Post a Comment