GithubHelp home page GithubHelp logo

crop's Introduction

Crop

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');

crop's People

Contributors

jdeniau avatar nmcquay avatar cheesesucker avatar themightychris avatar mcuadros avatar christiandavilakoobin avatar ecaron avatar wapmorgan avatar willjosefi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.