CropBalanced

Extends \stojg\crop\Crop

CropBalanced

This class calculates the most interesting point in the image by:

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

Refactor to make cleaner

todo

Rename the class to something more sensible

Methods

get special offset for class

getSpecialOffset(\Imagick $original, int $targetWidth, int $targetHeight) : array

Arguments

$original

\Imagick

$targetWidth

int

$targetHeight

int

Response

array

getRandomEdgeOffset

getRandomEdgeOffset(\Imagick $original, int $targetWidth, int $targetHeight) : array

Arguments

$original

\Imagick

$targetWidth

int

$targetHeight

int

Response

array

getOffsetBalanced

getOffsetBalanced(int $targetWidth, int $targetHeight) : array
todo

refactor so it follows DRY

Arguments

$targetWidth

int

$targetHeight

int

Response

array

By doing random sampling from the image, find the most energetic point on the passed in image

getHighestEnergyPoint(\Imagick $image) : array

Arguments

$image

\Imagick

Response

array

Profiling method

start() 
inherited static

Profiling method

mark() : string
inherited static

Response

string

__construct

__construct(string $imagePath) 
inherited

Arguments

$imagePath

string

  • The path to an image to load. Paths can include wildcards for file names, or can be URLs.

Get the area in pixels for this image

area(\Imagick $image) : int
inherited

Arguments

$image

\Imagick

Response

int

Resize and crop the image so it dimensions matches $targetWidth and $targetHeight

resizeAndCrop(int $targetWidth, int $targetHeight) : boolean|\Imagick
inherited

Arguments

$targetWidth

int

$targetHeight

int

Response

boolean|\Imagick

Returns width and height for resizing the image, keeping the aspect ratio and allow the image to be larger than either the width or height

getSafeResizeOffset(\Imagick $image, int $targetWidth, int $targetHeight) : array
inherited

Arguments

$image

\Imagick

$targetWidth

int

$targetHeight

int

Response

array

Returns a YUV weighted greyscale value

rgb2bw(int $r, int $g, int $b) : int
inherited
see

Arguments

$r

int

$g

int

$b

int

Response

int

getEntropy

getEntropy(array $histogram, int $area) : float
inherited

Arguments

$histogram

array

  • a value[count] array

$area

int

Response

float

Properties

Timer used for profiler / debugging

start_time
inherited static
var

originalImage

originalImage
inherited
var