定制 stojg/crop 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stojg/crop

最新稳定版本:1.4.0

Composer 安装命令:

composer require stojg/crop

包简介

Image cropping classes

关键字:

README 文档

README

This is a small set of image croppers that I created for testing automated cropping.

Build Status Scrutinizer Quality Score Code Coverage

Requirements

  • PHP 5.3
  • Imagemagick where the default colorspace being sRGB (ver 6.7.5-5 or higher)

Description

This little project includes three functional image cropers:

CropCenter

This is the most basic of cropping techniques:

  1. Find the exact center of the image
  2. Trim any edges that is bigger than the targetWidth and targetHeight

CropEntropy

This class finds the a position in the picture with the most "energy" in it. Energy (or entropy) in images are defined by 'edginess' in the image. For example a image of the sky have low edginess and an image of an anthill has very high edginess.

Energy is in this case calculated like this

  1. Take the image and turn it into black and white
  2. Run a edge filter so that we're left with only edges.
  3. Find a piece in the picture that has the highest entropy (i.e. most edges)
  4. Return coordinates that makes sure that this piece of the picture is not cropped 'away'

CropBalanced

Crop balanced is a variant of CropEntropy where I tried to the cropping a bit more balanced.

  1. Dividing the image into four equally squares
  2. Find the most energetic point per square
  3. Finding the images weighted mean interest point for all squares

CropFace

Crop face uses PHP Facedetect Extension (which uses OpenCV).

In details, the FaceCrop uses Entropy Crop but puts blocking "limits" on the faces. If the program faces two limits, we let the entropy decide the best crop.

Usage

$center = new \stojg\crop\CropCenter($filepath);
$croppedImage = $center->resizeAndCrop($width, $height);
$croppedImage->writeimage('assets/thumbs/cropped-center.jpg');

统计信息

  • 总下载量: 464.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 263
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 259
  • Watchers: 20
  • Forks: 40
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2
  • 更新时间: 2013-01-13