# tclip **Repository Path**: jary/tclip ## Basic Information - **Project Name**: tclip - **Description**: 图片智能裁剪 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-18 - **Last Updated**: 2021-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Install tclip extension for PHP7 on centos7 ``` 用于图片裁剪,有以下特点: 1、能进行人脸识别。图片中有人脸,将自动视为人脸区域为重要区域,将不会被裁剪掉。 2、自动识别其它重要区域。如果图片中未识别出人脸,则会根据特征分布计算出重区域。 总而言之,自动识别图片中的重要区域,并且在图片裁剪时保留重要区域。 3、可以加水印。 ``` #### Description ``` tcp ( string sourcepath, string destpath, int width, int height [, array param] ):bool ``` #### Parameters ``` sourcepath 源图片绝对路径 destpaht 目标图片绝对路径 width 目标宽度 height 目标长度 param 水印参数 可为字符串或者数组 字符串, 默认水印白色 数组格式 [ 'text' => string, // '水印文字', 'font' => int, // 水印字体大小 'x' => int, //水印x轴 'y' => int, //水印y轴 'color' => string,//色值,例如 #ffffff //也可以选用red,green,blue方式分别指定 'red' => int, 'green' => int, 'blue' => int, //厚度 'thickness' => int, 'scale' =>float ] ``` #### soft service version ``` cmake 3.18 opencv 4.3 opencv_contrib-4.3 php 7.2 ``` #### cmake install ``` > wget https://github.com/Kitware/CMake/releases/download/v3.18.0-rc1/cmake-3.18.0-rc1.tar.gz > tar -zxvf cmake-3.18.0-rc1.tar.gz > cd cmake-3.18.0-rc1 > ./configure --prefix=/usr/local > make && make install > hash -r ``` #### opencv install ``` > tar -zxvf opencv_contrib-4.3.tar.gz > tar -zxvf opencv4.3.tar.gz > cd opencv4.3/ && mkdir build && cd build > cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.3.0/modules .. > make && make install ``` #### system setting ``` > cp unix-install/opencv4.pc /usr/lib/pkgconfig/ > cp -p /etc/profile{,.$(date +%F_%T)} # 在/etc/profile unset i前增加PKG_CONFIG_PATH > grep '^PKG_CONFIG_PATH' /etc/profile||sed -i '/^unset i/iexport PKG_CONFIG_PATH=/usr/lib/pkgconfig/:$PKG_CONFIG_PATH' /etc/profile > source /etc/profile > [[ -f /etc/ld.so.conf.d/opencv.conf ]] && cp -p /etc/ld.so.conf.d/opencv.conf{,.$(date +%F)} > echo "/usr/local/lib/" > /etc/ld.so.conf.d/opencv.conf > ldconfig ``` #### tclip install ``` > tar -zxvf tclip.tar.gz > mv tclip phpsourcedir/ext/ > cd phpsourcedir/ext > phpize > ./configure --with-php-config=/usr/loca/php/bin/php-config > make > make test > make install ``` #### example