phash php,安装php phash扩展

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值