fsdfas
分类: Web开发
2013-03-30 15:00:57
Download required libraries
$ cd ~/download $ yum install libsndfile-devel unzip $ wget $ wget $ wget $ wget
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.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 $ make && make install Compile the PHP extension $ cd bindings/php $ phpize $ ./configure LIBS="-lpthread"
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.