Compare Images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nitro

    Compare Images

    Does anyone know a simple way to compare two images to see if they are
    the same? The filenames of the images will be different, but if the
    image data is the same I would like to test for that.

    The files will be jpeg images.

  • BLob

    #2
    Re: Compare Images

    > Does anyone know a simple way to compare two images to see if they are[color=blue]
    > the same? The filenames of the images will be different, but if the
    > image data is the same I would like to test for that.[/color]

    Just compare the md5 codes of the two files :

    if (md5(file_get_c ontents($filena me01)) ==
    md5(file_get_co ntents($filenam e02))) {
    echo "The files are the same";
    } else {
    echo "The files are not the same";
    }
    [color=blue]
    > The files will be jpeg images.[/color]

    The md5 should work for any type of file.

    BLob


    Comment

    • no-1

      #3
      Re: Compare Images

      do you mean, are the files from the same original source? or do they
      "look" the same?

      You could use an OS level cmp (compare) utility -- Four Unix utilities,
      cmp, comm and diff/sdiff, can be used to compare the contents of two
      files.

      to see if they "look" the same requires special recognition software
      that - generally speaking - only governmental agencies can afford.

      or:



      Comment

      Working...