PHP Класс Instafilter\Filter

This holds all of the common things between filters like getting access to the imagemagick instance etc.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( array $configuration = [] )
apply_filter ( ) You should only call this when you're ready to save, it often overwrites your image a few times (not always though) *
brightness_contrast ( integer $brightness, integer $contrast ) : Filter Replicate brightness/contrast photoshop function
colorize ( string $color, integer $composition = Imagick::COMPOSITE_MULTIPLY ) : Filter Replicate Colorize function
curves ( array $points, integer $channel = null ) : Filter Replicate photoshop's curves function
curves_graph ( string $fx ) : Filter Perform an imagemagick-style function on each pixel
exec ( string $command, string $params ) : Filter Execute a manual CLI command -- normally used when there's no PHP alternatice
gamma ( float $gamma, integer $channel = null ) : Filter Change the gamma of an image
hsl ( integer $hue, integer $saturation, integer $lightness ) : Filter Replicate HSL function
image ( &$image = null )
imagick ( &$imagick = null ) This is the imagemagick instance to perform the filters on
levels ( float $gamma = 1, integer $input_min, integer $input_max = 255, integer $output_min, integer $output_max = 255, integer $channel = Imagick::CHANNEL_ALL ) : Filter Replicate Photoshop's levels function.
vignette ( string $color, integer $composition = Imagick::COMPOSITE_DEFAULT, float $crop_factor = 1.5 ) : Filter Adds a vignette to the image

Приватные методы

Метод Описание
_exec ( type $program, type $params, type $passthru = false ) : type Execute the command

Описание методов

__construct() публичный Метод

public __construct ( array $configuration = [] )
$configuration array

apply_filter() абстрактный публичный Метод

You should only call this when you're ready to save, it often overwrites your image a few times (not always though) *
abstract public apply_filter ( )

brightness_contrast() публичный Метод

Now this one is a bit of a pain. PHP's extension doesn't provide us with this handle (yet?) So we have to save the image to disk at this point, perform the function using the command line, and reload the image. yay.
public brightness_contrast ( integer $brightness, integer $contrast ) : Filter
$brightness integer this is should be -150 <= brightnes <= 150. 0 for no change.
$contrast integer this is should be -150 <= contrast <= 150. 0 for no change.
Результат Filter

colorize() публичный Метод

Replicate Colorize function
public colorize ( string $color, integer $composition = Imagick::COMPOSITE_MULTIPLY ) : Filter
$color string a hex or rgb(a) color
$composition integer use imagicks constants here
Результат Filter

curves() публичный Метод

This takes a series of points and generates a function for the graph that fits the points. That function is then applied to each pixes, as in photoshop. It should use curves_graph once the function has been generated.
public curves ( array $points, integer $channel = null ) : Filter
$points array an array of arrays. array(array(12, 32), array(32,56)) etc.
$channel integer use imagemagicks contants here
Результат Filter

curves_graph() публичный Метод

Perform an imagemagick-style function on each pixel
public curves_graph ( string $fx ) : Filter
$fx string the function
Результат Filter

exec() публичный Метод

Execute a manual CLI command -- normally used when there's no PHP alternatice
public exec ( string $command, string $params ) : Filter
$command string normally 'convert'
$params string the CLI params
Результат Filter

gamma() публичный Метод

Change the gamma of an image
public gamma ( float $gamma, integer $channel = null ) : Filter
$gamma float normally between 0.8 and 2
$channel integer Use the Imagick constants for this
Результат Filter

hsl() публичный Метод

Imagemagick calls this 'modulate '
public hsl ( integer $hue, integer $saturation, integer $lightness ) : Filter
$hue integer -100 <= hue <= 100. 0 is no change.
$saturation integer -100 <= hue <= 100. 0 is no change.
$lightness integer -100 <= hue <= 100. 0 is no change.
Результат Filter

image() публичный Метод

public image ( &$image = null )

imagick() публичный Метод

It's recommended you supply a temporary file here! Some functions, such as brightness_contrast, overwrite the image.
public imagick ( &$imagick = null )

levels() публичный Метод

Replicate Photoshop's levels function.
public levels ( float $gamma = 1, integer $input_min, integer $input_max = 255, integer $output_min, integer $output_max = 255, integer $channel = Imagick::CHANNEL_ALL ) : Filter
$gamma float
$input_min integer between 0 and 255, same as photoshops
$input_max integer between 0 and 255, same as photoshops
$output_min integer between 0 and 255, same as photoshops
$output_max integer between 0 and 255, same as photoshops
$channel integer use imagemagicks constants
Результат Filter

vignette() публичный Метод

Adds a vignette to the image
public vignette ( string $color, integer $composition = Imagick::COMPOSITE_DEFAULT, float $crop_factor = 1.5 ) : Filter
$color string the colour of the vignette
$composition integer an imagick constant defining the composition to use
$crop_factor float defines the strenth of the vignette
Результат Filter