Php image cropping extension tclip

Source: Internet
Author: User
Used for image cropping. It has the following features: 1. It can be used for face recognition. The image contains a face, which is automatically regarded as an important area of the face and will not be cropped out. 2. automatically identify other important areas. If the image does not recognize the face, the heavy area is calculated based on the feature distribution. All in all, it automatically identifies important areas in the image and ensures that the image is cropped.

Used for image cropping. It has the following features: 1. It can be used for face recognition. The image contains a face, which is automatically regarded as an important area of the face and will not be cropped out. 2. automatically identify other important areas. If the image does not recognize the face, the heavy area is calculated based on the feature distribution. All in all, it automatically identifies important areas in the image and ensures that the image is cropped.

Used for image cropping. It has the following features:

1. Able to perform face recognition. The image contains a face, which is automatically regarded as an important area of the face and will not be cropped out.

2. automatically identify other important areas. If the image does not recognize the face, the heavy area is calculated based on the feature distribution.

All in all, it automatically identifies important areas in the image and retains important areas when cropping the image.

Currently, it has been used for taotao

Demo:

Source image:

The image size is 400*225 in the middle. The effect is as follows:

You can use tclip to crop an image as follows:

Installation Steps

Source code download

Opencv2 ?? Http://www.opencv.org.cn/index.php/Download

Install opencv2

This extension depends on opencv2.0. Therefore, install opencv before installation. Follow these steps to install opencv:

Yum install gtk +-devel pkgconfig libpng zlib libjpeg libtiff cmakewget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.4/OpenCV-2.4.4a.tar.bz2? R = http % 3A % 2F % 2Fwww.opencv.org.cn % 2Findex. php % 2 FDownload & ts = 1375240385 & use_mirror = ncutar jxvf OpenCV-2.4.4a.tar.bz2cd opencv-2.4.4/cmake CMakeLists.txt make & make installvim/etc/profile # Add export PKG_CONFIG_PATH =/usr/lib before unset I /pkgconfig /: /usr/local/lib/pkgconfig: $ PKG_CONFIG_PATH # After you exit, run the following command source/etc/profileecho "/usr/local/lib/">/etc/ld. so. conf. d/opencv. confldconfig

Install tclip Extension

Download source code: http://code.taobao.org/svn/tclip/trunk

# Cd to the php_ext Folder/usr/local/php5/bin/phpize in the source code directory. /configure -- with-php-config =/usr/local/php5/bin/php-configmake & make install # modify php. ini. Add extension = tclip. so # restart fpm. # Check whether the file is successfully loaded. php-I | grep tcliptcliptclip support => enabledtclip. face_config_path => no value

Install command line

# Enter chmod + x./tclip. sh./tclip. sh in the soft folder of the source code.
Usage instructions

First: use the format in php:

Tclip (original file path, save path of the cropped image, width of the cropped image, and height of the cropped image)

Example:

$source_file = "/tmp/a.jpg";$dest_file = "/www/a_dest.jpg";$width = 400;$height = 200;tclip($source_file, $dest_file, $width, $height);

Type 2: Command Line

Parameter description:-s source image path-d save path of the cropped image-w width of the cropped image-h height of the cropped image. /tclip-s a.jpg-d a_dest.jpg-w 400-h 200

Source: http://www.oschina.net/p/tclip

Used for image cropping. It has the following features: 1. It can be used for face recognition. The image contains a face, which is automatically regarded as an important area of the face and will not be cropped out. 2. automatically identify other important areas. If the image does not recognize the face, the heavy area is calculated based on the feature distribution. All in all, it automatically identifies important areas in the image and retains important areas when cropping the image. Currently, it has been used for demonstration of the effect of a Taobao PLAYER: source image: the size of a large image is 400*225 in the middle. The effect is as follows: the effect of cropping Images Using tclip is as follows: Install the source code to download opencv2 ?? Http://www.opencv.org.cn/index.php/Download install opencv2 this extension depends on opencv2.0. Therefore, install opencv before installation. Opencv installation steps are as follows install tclip extension download source code: http://code.taobao.org/svn/tclip/trunk installation command line instructions first: in php using format: tclip (File Original path, cropped image save path, image Width after cropping, Image Height after cropping) Example: Second: Command Line Source: http://www.oschina.net/p/tclip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.