phash php扩展

Download required libraries

$ cd ~/download
$ yum install libsndfile-devel unzip
$ wget https://downloads.sourceforge.net/project/cimg/CImg-1.5.4.zip
$ wget http://phash.org/releases/pHash-0.9.5.tar.gz
$ wget http://www.mega-nerd.com/SRC/libsamplerate-0.1.8.tar.gz
$ wget http://sourceforge.net/projects/mpg123/files/mpg123/1.15.1/mpg123-1.15.1.tar.bz2/download

Compile required library for pHash. We need to enable the audio and image support because of the PHP extension.

$ tar xvf libsamplerate-0.1.8.tar.gz
$ cd libsamplerate-0.1.8
$ ./configure
$ make && make install
$
$ tar xvf mpg123-1.15.1
$ cd mpg123-1 generic ventolin online.15.1
$ ./configure
$ make && make install
We need to copy CImg.h in the /user/local/include folder
$ unzip CImg-1.5.4.zip
$ cp CImg-1.5.4/CImg.h /usr/local/include

Compile pHash library

$ tar xvf pHash-0.9.5.tar.gz
$ cd pHash-0.9.5
$ ./configure --enable-video-hash=no LIBS="-lpthread"
$ make && make install
Compile the PHP extension
$ cd bindings/php
$ phpize
$ ./configure LIBS="-lpthread" --with-php-config=/usr/local/php/bin/php-config

Edit pHash.cpp

I had to edit pHash.cpp to fix a compilation error. I think you only need to do it if you are using php >=5.3

$ vi /root/download/pHash-0.9.5/bindings/php/pHash.cpp
# line 106, replace "function_entry" by "zend_function_entry"
# save and close
Finish the compilation
$ make
$ make test
$ make install
# finally enable pHash in the php.ini adding extension=pHash.so
# restart apache

Optional – If you want to store the hash in the database (SQL):

You need to edit the pHash.cpp to modify the return value to the hash.

By default ph_dct_imagehash($file) return a *ulong64 (pointer) we need to retrieve a string to store it in the database.

Call to undefined function mysql_connect()

1、检查php.ini中的extension=php_mysql.dl有没有去掉注释(;为注释符)
2、检查php.ini中的extension_dir有没有设对路径(一般设为 php安装目录\ext);
3、复制php安装根目录下lib开头的dll到C:\WINDOWS\system32目录下;
4、以上步骤完成后,重启下apache……

按以上方法检查过了,还是不行。。。

最后看到网上说是把libmysql.dll复制到C:\Windows目录下面,结果解决了。。。