例如:
$f='http://da.feedsportal.com/r/1311026036/u/173/f/628983/c/33390/s/1311026036/a2.img';
$f2='http://da.feedsportal.com/r/1451157015/u/173/f/628983/c/33390/s/1451157015/a2.img';f和f2是同一张图,md5-file返回的值一样,再如:
$f='http://www.wuchuan123.com/images/10034.jpg';
$f2='http://www.wuchuan123.com/images/10034/90x60.jpg';f2是f的一个宽和高重写我写了一个rss reader,抓信息的时候我想过滤一下图片,像f和f2这样的情况都算一张图

解决方案 »

  1.   


    $f1='http://www.wuchuan123.com/images/10034.jpg';
    $f2='http://www.wuchuan123.com/images/10034/90x60.jpg';

    $content1 = base64_encode(file_get_contents($f1));
    $content2 = base64_encode(file_get_contents($f2));

    if($content1 == $content2)
    echo "same";
    else 
    echo "notsame";
      

  2.   

    LZ试试。。我用base64_encode 是因为 图片读取出来是很多乱码的,先64一下 方便程序比较!
      

  3.   

    后两张图片的相似度是 0.875,算作一张也可以
    正好前两天帮人弄了个图片指纹$f3 = 'http://www.wuchuan123.com/images/10034.jpg';
    $f4 = 'http://www.wuchuan123.com/images/10034/90x60.jpg';$p1 = produceFingerPrint($f3);
    $p2 = produceFingerPrint($f4);
    $n = count(array_diff_assoc(str_split($p1), str_split($p2)));
    echo 1 - $n / 64;/**
     * 生成指纹
     * $filename 图片文件名,可以是URL。只能是GD支持的图片类型
     * $retmode 返回格式:0 二进制表示 1 数组 2 十六进制表示
     **/
    function produceFingerPrint($filename, $retmode=0) {
      $sim = imagecreatefromstring( file_get_contents($filename) );
      $dim = imagecreate(8, 8);
      imagecopyresized($dim, $sim, 0, 0, 0, 0, 8, 8, imagesx($sim), imagesy($sim));
      imagetruecolortopalette($sim, true, 64);
      //imagefilter($sim, IMG_FILTER_GRAYSCALE);  for($x=0; $x<8; $x++) for($y=0; $y<8; $y++) {
        $c = imagecolorat($dim, $x, $y);
        $p[] = array_sum( imagecolorsforindex($dim, $c))/3;
      }
      $avl = array_sum($p)/count($p);
      $r = '';
      foreach($p as $v) $r .= $v>=$avl ? 1 : 0;  if($retmode == 0) return $r;
      $p = array_map('bindec', str_split($r, 8));
      if($retmode == 1) return $p;
      if($retmode == 2) {
        array_unshift($p, '%02x%02x%02x%02x%02x%02x%02x%02x');
        return call_user_func_array('sprintf', $p);
      }
      return false;
    }
      

  4.   

    厉害,如果是我,只能想到md5_file
      

  5.   

    如果rss a源和b源md5_file对宽和高重写返回值不一样
      

  6.   

    版主的函数对:$f='http://da.feedsportal.com/r/1311026036/u/173/f/628983/c/33390/s/1311026036/a2.img';
    $f2='http://da.feedsportal.com/r/1451157015/u/173/f/628983/c/33390/s/1451157015/a2.img';
    这种会抛错误