Skip to content

Instantly share code, notes, and snippets.

@SeanRoberts
Forked from jamesmontalvo3/phash.sh
Created November 16, 2019 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanRoberts/0a39a5859efb3afb8976e1a115cbba8c to your computer and use it in GitHub Desktop.
Save SeanRoberts/0a39a5859efb3afb8976e1a115cbba8c to your computer and use it in GitHub Desktop.
Install phash
#!/bin/sh
#
#
# Download required libraries
cd ~
mkdir download
cd download
yum install -y libsndfile-devel unzip
wget http://cimg.eu/files/CImg_latest.zip
wget http://www.phash.org/releases/pHash-0.9.6.tar.gz
# JUST FOR AUDIO? Fails without...
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 libraries for pHash if audio and video required
# AUDIO
~/download
tar xvf libsamplerate-0.1.8.tar.gz
cd libsamplerate-0.1.8
./configure
make && make install
# AUDIO
~/download
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
cd ~/download
unzip CImg_latest.zip
cp CImg*/CImg.h /usr/local/include
# Compile pHash library
tar xvf pHash-0.9.6.tar.gz
cd pHash-0.9.6
./configure --enable-video-hash=no --enable-audio-hash=no --enable-pthread
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
# line 106, replace "function_entry" by "zend_function_entry"
# save and close
# $ vi /root/download/pHash-0.9.5/bindings/php/pHash.cpp
# Finish the compilation
$ make
$ make test
$ make install
# finally enable pHash in the php.ini adding extension=pHash.so
# restart apache
cd ~/desdrive
npm install phash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment