Home >Backend Development >PHP Tutorial >MacOS Install PHP image cropping extension Tclip_PHP tutorial
Tclip is an automatic avatar recognition, PHP image cropping project. It can automatically identify important areas in the picture and retain the important areas when cropping the picture. Let’s take a look at how to install it on MacOS.
Tclip is used for image cropping and has the following features:
Can perform face recognition. If there is a face in the picture, the face area will automatically be regarded as an important area and will not be cropped.
Automatically identify other important areas. If no face is recognized in the image, the heavy area is calculated based on the feature distribution.
In summary, important areas in an image are automatically identified and retained when cropping the image.
Source code address: https://github.com/exinnet/tclip
Install opencv
According to the instructions on github, there is no problem installing on CentOS, but it hangs on my MacOS.
The first problem encountered is that opencv cannot be installed. Fortunately, I downloaded the latest opencv-2.4.11 from github and installed it successfully.
Download address: https://github.com/Itseez/opencv/releases
Use the latest version of OpenCV 2.4.11
Install dependencies
Before installing opencv, install some dependency packages:
The code is as follows:
Tips: For the installation and use of brew, please refer to http://brew.sh/
Install opencv
Start installing opencv:
The code is as follows:
Install php tclip
Download first: https://github.com/exinnet/tclip/archive/master.zip
Then continue:
The code is as follows:
If nothing else happens, you should be dead at this point. Tip:
The code is as follows:
On the Tclip author’s page http://www.bo56.com/tclip face recognition image cropping/#download
In the comments, some netizens also encountered similar problems and suggested the following modifications:
Change the judgment statement test ${i:${#i}-3} = “.so” in config.m4 to test ${i:${#i}-6} = “.dylib” , and try to rename the 46-line .so to .dylib
Still prompting no result error~
Look through the code of config.m4 and execute pkg-config opencv --libs --cflags. The output of opencv:
The code is as follows:
I felt something was wrong, so I ran to the server where Linux was successfully installed and executed it. The output was as follows:
The code is as follows:
Look at his judgment code again:
The code is as follows:
I immediately understood that the output on Linux are all specific .so paths, and on MacOS they are all relative paths, while config.m4 is judged based on the specific path and extension. Once I understand the problem, I can solve it. Simple.
Modify the execution result of pkg-config opencv --libs --cflags opencv to the specific path and replace it in config.m4:
The code is as follows:
Continue execution:
The code is as follows:
The installation was successfully completed.
The above is the entire content of this article, I hope you all like it.