Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/06/2017, 15:51
maxhy
 
Fecha de Ingreso: enero-2015
Mensajes: 32
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: [Imagenes] Comprar 2 Imagenes

Cita:
Iniciado por alvaro_trewhela Ver Mensaje
Edito: Te dejo lo que haría, no se si es optimo, o si hay otros métodos:

Código PHP:
Ver original
  1. function identImgs($img1,$img2){
  2. $info1 = getimagesize($img1);
  3. $info2 = getimagesize($img2);
  4.  
  5.     if($info1[0] != $info2[0] || $info1[1] != $info2[1]){ return false; }
  6.    
  7.     if($info1["mime"] == "image/jpeg"){
  8.     $img1 = imagecreatefromjpeg($img1);
  9.     }
  10.     else if($info1["mime"] == "image/png"){
  11.     $img1 = imagecreatefrompng($img1);
  12.     }
  13.     else if($info1["mime"] == "image/bmp"){
  14.     $img1 = imagecreatefrombmp($img1);
  15.     }
  16.     else if($info1["mime"] == "image/gif"){
  17.     $img1 = imagecreatefromgif($img1);
  18.     }
  19.     else{
  20.     return false;
  21.     }
  22.    
  23.     if($info2["mime"] == "image/jpeg"){
  24.     $img2 = imagecreatefromjpeg($img2);
  25.     }
  26.     else if($info2["mime"] == "image/png"){
  27.     $img2 = imagecreatefrompng($img2);
  28.     }
  29.     else if($info2["mime"] == "image/bmp"){
  30.     $img2 = imagecreatefrombmp($img2);
  31.     }
  32.     else if($info2["mime"] == "image/gif"){
  33.     $img2 = imagecreatefromgif($img2);
  34.     }
  35.     else{
  36.     return false;
  37.     }
  38.    
  39.     for($x=0;$x<$info1[0];$x++){
  40.         for($y=0;$y<$info1[1];$y++){
  41.             if(imagecolorat($img1, $x, $y) != imagecolorat($img2, $x, $y)){ return false; }
  42.         }
  43.     }
  44. return true;
  45. }

Te devuelve true si son identicos.

Saludos.
Queria saber si las imagenes estan en carpetas y dichas ubicaciones estan en la base de datos. Como hago para compararlas a todas las que estan en la base de datos??