From e8e7251b9d6f29cc50c8bbcd04fc98dc6bff7b52 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Wed, 14 May 2014 20:13:53 +0200 Subject: [PATCH] Added DocBlocks --- src/Intervention/Image/AbstractColor.php | 102 +++++++++++++++ src/Intervention/Image/AbstractDriver.php | 62 +++++++++ src/Intervention/Image/AbstractEncoder.php | 50 ++++++++ src/Intervention/Image/AbstractFont.php | 8 ++ src/Intervention/Image/AbstractShape.php | 39 +++++- src/Intervention/Image/AbstractSource.php | 90 ++++++++++++- .../Image/Commands/AbstractCommand.php | 43 +++++++ src/Intervention/Image/Commands/Argument.php | 43 +++++++ .../Image/Commands/ChecksumCommand.php | 6 + .../Image/Commands/CircleCommand.php | 6 + .../Image/Commands/EllipseCommand.php | 6 + .../Image/Commands/ExifCommand.php | 9 ++ .../Image/Commands/LineCommand.php | 6 + .../Image/Commands/RectangleCommand.php | 6 + .../Image/Commands/ResponseCommand.php | 6 + .../Image/Commands/TextCommand.php | 5 + src/Intervention/Image/Constraint.php | 49 ++++++++ src/Intervention/Image/File.php | 34 +++++ src/Intervention/Image/Filters/DemoFilter.php | 19 +++ .../Image/Filters/FilterInterface.php | 6 + src/Intervention/Image/Gd/Color.php | 96 +++++++++++++- .../Image/Gd/Commands/BackupCommand.php | 6 + .../Image/Gd/Commands/BlurCommand.php | 6 + .../Image/Gd/Commands/BrightnessCommand.php | 6 + .../Image/Gd/Commands/ColorizeCommand.php | 6 + .../Image/Gd/Commands/ContrastCommand.php | 6 + .../Image/Gd/Commands/CropCommand.php | 6 + .../Image/Gd/Commands/DestroyCommand.php | 6 + .../Image/Gd/Commands/FillCommand.php | 6 + .../Image/Gd/Commands/FitCommand.php | 8 +- .../Image/Gd/Commands/FlipCommand.php | 6 + .../Image/Gd/Commands/GammaCommand.php | 6 + .../Image/Gd/Commands/GetSizeCommand.php | 6 + .../Image/Gd/Commands/GreyscaleCommand.php | 6 + .../Image/Gd/Commands/HeightenCommand.php | 6 + .../Image/Gd/Commands/InsertCommand.php | 6 + .../Image/Gd/Commands/InterlaceCommand.php | 6 + .../Image/Gd/Commands/InvertCommand.php | 6 + .../Image/Gd/Commands/LimitColorsCommand.php | 6 + .../Image/Gd/Commands/MaskCommand.php | 6 + .../Image/Gd/Commands/OpacityCommand.php | 6 + .../Image/Gd/Commands/PickColorCommand.php | 6 + .../Image/Gd/Commands/PixelCommand.php | 6 + .../Image/Gd/Commands/PixelateCommand.php | 6 + .../Image/Gd/Commands/ResetCommand.php | 6 + .../Image/Gd/Commands/ResizeCanvasCommand.php | 6 + .../Image/Gd/Commands/ResizeCommand.php | 6 + .../Image/Gd/Commands/RotateCommand.php | 6 + .../Image/Gd/Commands/TrimCommand.php | 6 + .../Image/Gd/Commands/WidenCommand.php | 6 + src/Intervention/Image/Gd/Driver.php | 23 +++- src/Intervention/Image/Gd/Encoder.php | 15 +++ src/Intervention/Image/Gd/Font.php | 1 + .../Image/Gd/Shapes/CircleShape.php | 18 +++ .../Image/Gd/Shapes/EllipseShape.php | 25 ++++ .../Image/Gd/Shapes/LineShape.php | 49 ++++++++ .../Image/Gd/Shapes/RectangleShape.php | 39 ++++++ src/Intervention/Image/Gd/Source.php | 26 +++- src/Intervention/Image/Image.php | 118 +++++++++++++++++- src/Intervention/Image/ImageManager.php | 29 +++++ src/Intervention/Image/ImageManagerStatic.php | 29 +++++ src/Intervention/Image/Imagick/Color.php | 110 ++++++++++++++++ .../Image/Imagick/Commands/BackupCommand.php | 6 + .../Image/Imagick/Commands/BlurCommand.php | 6 + .../Imagick/Commands/BrightnessCommand.php | 6 + .../Imagick/Commands/ColorizeCommand.php | 6 + .../Imagick/Commands/ContrastCommand.php | 6 + .../Image/Imagick/Commands/CropCommand.php | 6 + .../Image/Imagick/Commands/DestroyCommand.php | 6 + .../Image/Imagick/Commands/FillCommand.php | 6 + .../Image/Imagick/Commands/FitCommand.php | 8 +- .../Image/Imagick/Commands/FlipCommand.php | 6 + .../Image/Imagick/Commands/GammaCommand.php | 6 + .../Image/Imagick/Commands/GetSizeCommand.php | 6 + .../Imagick/Commands/GreyscaleCommand.php | 6 + .../Imagick/Commands/HeightenCommand.php | 6 + .../Image/Imagick/Commands/InsertCommand.php | 6 + .../Imagick/Commands/InterlaceCommand.php | 6 + .../Image/Imagick/Commands/InvertCommand.php | 6 + .../Imagick/Commands/LimitColorsCommand.php | 6 + .../Image/Imagick/Commands/MaskCommand.php | 6 + .../Image/Imagick/Commands/OpacityCommand.php | 6 + .../Imagick/Commands/PickColorCommand.php | 6 + .../Image/Imagick/Commands/PixelCommand.php | 6 + .../Imagick/Commands/PixelateCommand.php | 6 + .../Image/Imagick/Commands/ResetCommand.php | 6 + .../Imagick/Commands/ResizeCanvasCommand.php | 6 + .../Image/Imagick/Commands/ResizeCommand.php | 6 + .../Image/Imagick/Commands/RotateCommand.php | 6 + .../Image/Imagick/Commands/TrimCommand.php | 6 + .../Image/Imagick/Commands/WidenCommand.php | 6 + src/Intervention/Image/Imagick/Driver.php | 23 +++- src/Intervention/Image/Imagick/Encoder.php | 15 +++ src/Intervention/Image/Imagick/Font.php | 1 + .../Image/Imagick/Shapes/CircleShape.php | 18 +++ .../Image/Imagick/Shapes/EllipseShape.php | 25 ++++ .../Image/Imagick/Shapes/LineShape.php | 49 ++++++++ .../Image/Imagick/Shapes/RectangleShape.php | 39 ++++++ src/Intervention/Image/Imagick/Source.php | 26 +++- src/Intervention/Image/Point.php | 33 +++++ src/Intervention/Image/Response.php | 29 +++++ src/Intervention/Image/Size.php | 92 ++++++++++++++ src/config/config.php | 14 ++- 103 files changed, 1872 insertions(+), 17 deletions(-) diff --git a/src/Intervention/Image/AbstractColor.php b/src/Intervention/Image/AbstractColor.php index 9378b002..50341e9e 100644 --- a/src/Intervention/Image/AbstractColor.php +++ b/src/Intervention/Image/AbstractColor.php @@ -4,23 +4,113 @@ namespace Intervention\Image; abstract class AbstractColor { + /** + * Initiates color object from integer + * + * @param integer $value + * @return Intervention\Image\AbstractColor + */ abstract public function initFromInteger($value); + + /** + * Initiates color object from given array + * + * @param array $value + * @return Intervention\Image\AbstractColor + */ abstract public function initFromArray($value); + + /** + * Initiates color object from given string + * + * @param string $value + * @return Intervention\Image\AbstractColor + */ abstract public function initFromString($value); + + /** + * Initiates color object from given ImagickPixel object + * + * @param ImagickPixel $value + * @return Intervention\Image\AbstractColor + */ abstract public function initFromObject($value); + + /** + * Initiates color object from given R, G and B values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @return Intervention\Image\AbstractColor + */ abstract public function initFromRgb($r, $g, $b); + + /** + * Initiates color object from given R, G, B and A values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @param float $a + * @return Intervention\Image\AbstractColor + */ abstract public function initFromRgba($r, $g, $b, $a); + + /** + * Calculates integer value of current color instance + * + * @return integer + */ abstract public function getInt(); + + /** + * Calculates hexadecimal value of current color instance + * + * @param string $prefix + * @return string + */ abstract public function getHex($prefix); + + /** + * Calculates RGB(A) in array format of current color instance + * + * @return array + */ abstract public function getArray(); + + /** + * Calculates RGBA in string format of current color instance + * + * @return string + */ abstract public function getRgba(); + + /** + * Determines if current color is different from given color + * + * @param AbstractColor $color + * @param integer $tolerance + * @return boolean + */ abstract public function differs(AbstractColor $color, $tolerance = 0); + /** + * Creates new instance + * + * @param string $value + */ public function __construct($value = null) { $this->parse($value); } + /** + * Parses given value as color + * + * @param mixed $value + * @return Intervention\Image\AbstractColor + */ public function parse($value) { switch (true) { @@ -55,6 +145,12 @@ abstract class AbstractColor return $this; } + /** + * Formats current color instance into given format + * + * @param string $type + * @return mixed + */ public function format($type) { switch (strtolower($type)) { @@ -89,6 +185,12 @@ abstract class AbstractColor } } + /** + * Reads RGBA values from string into array + * + * @param string $value + * @return array + */ protected function rgbaFromString($value) { $result = false; diff --git a/src/Intervention/Image/AbstractDriver.php b/src/Intervention/Image/AbstractDriver.php index d1ad47d3..b71235ff 100644 --- a/src/Intervention/Image/AbstractDriver.php +++ b/src/Intervention/Image/AbstractDriver.php @@ -4,19 +4,70 @@ namespace Intervention\Image; abstract class AbstractDriver { + /** + * Source instance to init images from + * + * @var Intervention\Image\AbstractSource + */ + public $source; + + /** + * Image encoder instance + * + * @var Intervention\Image\AbstractEncoder + */ + public $encoder; + + /** + * Creates new image instance + * + * @param integer $width + * @param integer $height + * @param string $background + * @return Intervention\Image\Image + */ abstract public function newImage($width, $height, $background); + + /** + * Reads given string into color object + * + * @param string $value + * @return AbstractColor + */ abstract public function parseColor($value); + /** + * Initiates new image from given input + * + * @param mixed $data + * @return Intervention\Image\Image + */ public function init($data) { return $this->source->init($data); } + /** + * Encodes given image + * + * @param Image $image + * @param string $format + * @param integer $quality + * @return Intervention\Image\Image + */ public function encode($image, $format, $quality) { return $this->encoder->process($image, $format, $quality); } + /** + * Executes named command on given image + * + * @param Image $image + * @param string $name + * @param array $arguments + * @return Intervention\Image\Commands\AbstractCommand + */ public function executeCommand($image, $name, $arguments) { $commandName = $this->getCommandClassName($name); @@ -26,6 +77,12 @@ abstract class AbstractDriver return $command; } + /** + * Returns classname of given command name + * + * @param string $name + * @return string + */ private function getCommandClassName($name) { $drivername = $this->getDriverName(); @@ -43,6 +100,11 @@ abstract class AbstractDriver ); } + /** + * Returns name of current driver instance + * + * @return string + */ public function getDriverName() { $reflect = new \ReflectionClass($this); diff --git a/src/Intervention/Image/AbstractEncoder.php b/src/Intervention/Image/AbstractEncoder.php index c85b61f4..66162a81 100644 --- a/src/Intervention/Image/AbstractEncoder.php +++ b/src/Intervention/Image/AbstractEncoder.php @@ -4,12 +4,42 @@ namespace Intervention\Image; abstract class AbstractEncoder { + /** + * Processes and returns encoded image as JPEG string + * + * @return string + */ abstract protected function processJpeg(); + + /** + * Processes and returns encoded image as PNG string + * + * @return string + */ abstract protected function processPng(); + + /** + * Processes and returns encoded image as GIF string + * + * @return string + */ abstract protected function processGif(); + /** + * Buffer of encode result data + * + * @var string + */ public $result; + /** + * Process a given image + * + * @param Image $image + * @param string $format + * @param integer $quality + * @return Intervention\Image\Image + */ public function process(Image $image, $format = null, $quality = null) { $this->setImage($image); @@ -44,6 +74,11 @@ abstract class AbstractEncoder return $image->setEncoded($this->result); } + /** + * Processes and returns encoded image as data-url string + * + * @return string + */ protected function processDataUrl() { return sprintf('data:%s;base64,%s', @@ -52,11 +87,21 @@ abstract class AbstractEncoder ); } + /** + * Sets image to process + * + * @param Intervention\Image\Image $image + */ protected function setImage($image) { $this->image = $image; } + /** + * Determines output format + * + * @param string $format + */ protected function setFormat($format = null) { if (is_null($format) && $this->image instanceof Image) { @@ -68,6 +113,11 @@ abstract class AbstractEncoder return $this; } + /** + * Determines output quality + * + * @param integer $quality + */ protected function setQuality($quality) { $quality = is_null($quality) ? 90 : $quality; diff --git a/src/Intervention/Image/AbstractFont.php b/src/Intervention/Image/AbstractFont.php index 923c7951..0a5c0db6 100644 --- a/src/Intervention/Image/AbstractFont.php +++ b/src/Intervention/Image/AbstractFont.php @@ -4,6 +4,14 @@ namespace Intervention\Image; abstract class AbstractFont { + /** + * Draws font to given image on given position + * + * @param Image $image + * @param integer $posx + * @param integer $posy + * @return boolean + */ abstract public function applyToImage(Image $image, $posx = 0, $posy = 0); /** diff --git a/src/Intervention/Image/AbstractShape.php b/src/Intervention/Image/AbstractShape.php index 7f4a6627..0ffc59ea 100644 --- a/src/Intervention/Image/AbstractShape.php +++ b/src/Intervention/Image/AbstractShape.php @@ -4,16 +4,41 @@ namespace Intervention\Image; abstract class AbstractShape { + /** + * Background color of shape + * + * @var string + */ public $background; + + /** + * Border color of current shape + * + * @var string + */ public $border_color; + + /** + * Border width of shape + * + * @var integer + */ public $border_width = 0; + /** + * Draws shape to given image on given position + * + * @param Image $image + * @param integer $posx + * @param integer $posy + * @return boolean + */ abstract public function applyToImage(Image $image, $posx = 0, $posy = 0); /** * Set text to be written * - * @param String $text + * @param string $text * @return void */ public function background($color) @@ -21,12 +46,24 @@ abstract class AbstractShape $this->background = $color; } + /** + * Set border width and color of current shape + * + * @param integer $width + * @param string $color + * @return void + */ public function border($width, $color = null) { $this->border_width = is_numeric($width) ? intval($width) : 0; $this->border_color = is_null($color) ? '#000000' : $color; } + /** + * Determines if current shape has border + * + * @return boolean + */ public function hasBorder() { return ($this->border_width >= 1); diff --git a/src/Intervention/Image/AbstractSource.php b/src/Intervention/Image/AbstractSource.php index 5da0d6ad..82d92d3d 100644 --- a/src/Intervention/Image/AbstractSource.php +++ b/src/Intervention/Image/AbstractSource.php @@ -4,18 +4,60 @@ namespace Intervention\Image; abstract class AbstractSource { + /** + * Initiates new image from path in filesystem + * + * @param string $path + * @return Intervention\Image\Image + */ abstract public function initFromPath($path); - abstract public function initFromBinary($data); - abstract public function initFromGdResource($resource); - abstract public function initFromImagick($object); + /** + * Initiates new image from binary data + * + * @param string $data + * @return Intervention\Image\Image + */ + abstract public function initFromBinary($data); + + /** + * Initiates new image from GD resource + * + * @param Resource $resource + * @return Intervention\Image\Image + */ + abstract public function initFromGdResource($resource); + + /** + * Initiates new image from Imagick object + * + * @param Imagick $object + * @return Intervention\Image\Image + */ + abstract public function initFromImagick(\Imagick $object); + + /** + * Buffer of input data + * + * @var mixed + */ private $data; + /** + * Creates new Source with data + * + * @param mixed $data + */ public function __construct($data = null) { $this->data = $data; } + /** + * Determines if current source data is GD resource + * + * @return boolean + */ public function isGdResource() { if (is_resource($this->data)) { @@ -25,16 +67,31 @@ abstract class AbstractSource return false; } + /** + * Determines if current source data is Imagick object + * + * @return boolean + */ public function isImagick() { return is_a($this->data, 'Imagick'); } + /** + * Determines if current source data is Intervention\Image\Image object + * + * @return boolean + */ public function isInterventionImage() { return is_a($this->data, '\Intervention\Image\Image'); } + /** + * Determines if current source data is file path + * + * @return boolean + */ public function isFilePath() { if (is_string($this->data)) { @@ -44,11 +101,21 @@ abstract class AbstractSource return false; } + /** + * Determines if current source data is url + * + * @return boolean + */ public function isUrl() { return (bool) filter_var($this->data, FILTER_VALIDATE_URL); } + /** + * Determines if current source data is binary data + * + * @return boolean + */ public function isBinary() { if (is_string($this->data)) { @@ -59,11 +126,23 @@ abstract class AbstractSource return false; } + /** + * Initiates new Image from Intervention\Image\Image + * + * @param Image $object + * @return Intervention\Image\Image + */ public function initFromInterventionImage($object) { return $object; } + /** + * Initiates new image from mixed data + * + * @param mixed $data + * @return Intervention\Image\Image + */ public function init($data) { $this->data = $data; @@ -100,6 +179,11 @@ abstract class AbstractSource } } + /** + * Source object transforms to string source data + * + * @return string + */ public function __toString() { return (string) $this->data; diff --git a/src/Intervention/Image/Commands/AbstractCommand.php b/src/Intervention/Image/Commands/AbstractCommand.php index c0d754ea..811ea5c4 100644 --- a/src/Intervention/Image/Commands/AbstractCommand.php +++ b/src/Intervention/Image/Commands/AbstractCommand.php @@ -4,31 +4,74 @@ namespace Intervention\Image\Commands; abstract class AbstractCommand { + /** + * Arguments of command + * + * @var array + */ public $arguments; + + /** + * Output of command + * + * @var mixed + */ protected $output; + /** + * Executes current command on given image + * + * @param Intervention\Image\Image $image + * @return mixed + */ abstract public function execute($image); + /** + * Creates new command instance + * + * @param array $arguments + */ public function __construct($arguments) { $this->arguments = $arguments; } + /** + * Creates new argument instance from given argument key + * + * @param integer $key + * @return Intervention\Image\Commands\Argument + */ public function argument($key) { return new \Intervention\Image\Commands\Argument($this, $key); } + /** + * Returns output data of current command + * + * @return mixed + */ public function getOutput() { return $this->output ? $this->output : null; } + /** + * Determines if current instance has output data + * + * @return boolean + */ public function hasOutput() { return ! is_null($this->output); } + /** + * Sets output data of current command + * + * @param mixed $value + */ public function setOutput($value) { $this->output = $value; diff --git a/src/Intervention/Image/Commands/Argument.php b/src/Intervention/Image/Commands/Argument.php index 6ca144cf..518d0c7a 100644 --- a/src/Intervention/Image/Commands/Argument.php +++ b/src/Intervention/Image/Commands/Argument.php @@ -4,21 +4,49 @@ namespace Intervention\Image\Commands; class Argument { + /** + * Command with arguments + * + * @var Intervention\Image\Commands\AbstractCommand + */ public $command; + + /** + * Key of argument in array + * + * @var integer + */ public $key; + /** + * Creates new instance from given command and key + * + * @param AbstractCommand $command + * @param integer $key + */ public function __construct(AbstractCommand $command, $key = 0) { $this->command = $command; $this->key = $key; } + /** + * Returns name of current arguments command + * + * @return string + */ public function getCommandName() { preg_match("/\\\\([\w]+)Command$/", get_class($this->command), $matches); return isset($matches[1]) ? lcfirst($matches[1]).'()' : 'Method'; } + /** + * Returns value of current argument + * + * @param mixed $default + * @return mixed + */ public function value($default = null) { $arguments = $this->command->arguments; @@ -28,6 +56,11 @@ class Argument } } + /** + * Defines current argument as required + * + * @return Intervention\Image\Commands\Argument + */ public function required() { if ( ! array_key_exists($this->key, $this->command->arguments)) { @@ -39,6 +72,11 @@ class Argument return $this; } + /** + * Determines that current argument must be of given type + * + * @return Intervention\Image\Commands\Argument + */ public function type($type) { $fail = false; @@ -93,6 +131,11 @@ class Argument return $this; } + /** + * Determines that current argument value must be numeric between given values + * + * @return Intervention\Image\Commands\Argument + */ public function between($x, $y) { $value = $this->type('numeric')->value(); diff --git a/src/Intervention/Image/Commands/ChecksumCommand.php b/src/Intervention/Image/Commands/ChecksumCommand.php index ef2f1c89..13f76893 100644 --- a/src/Intervention/Image/Commands/ChecksumCommand.php +++ b/src/Intervention/Image/Commands/ChecksumCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Commands; class ChecksumCommand extends AbstractCommand { + /** + * Calculates checksum of given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $colors = array(); diff --git a/src/Intervention/Image/Commands/CircleCommand.php b/src/Intervention/Image/Commands/CircleCommand.php index 9ae085b8..438c93a6 100644 --- a/src/Intervention/Image/Commands/CircleCommand.php +++ b/src/Intervention/Image/Commands/CircleCommand.php @@ -6,6 +6,12 @@ use \Closure; class CircleCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draw a circle centered on given image + * + * @param Intervention\Image\image $image + * @return boolean + */ public function execute($image) { $x = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Commands/EllipseCommand.php b/src/Intervention/Image/Commands/EllipseCommand.php index 85ef0eb5..02d99642 100644 --- a/src/Intervention/Image/Commands/EllipseCommand.php +++ b/src/Intervention/Image/Commands/EllipseCommand.php @@ -6,6 +6,12 @@ use \Closure; class EllipseCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draws ellipse on given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $x = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Commands/ExifCommand.php b/src/Intervention/Image/Commands/ExifCommand.php index 89e69b84..cbea0f69 100644 --- a/src/Intervention/Image/Commands/ExifCommand.php +++ b/src/Intervention/Image/Commands/ExifCommand.php @@ -4,6 +4,15 @@ namespace Intervention\Image\Commands; class ExifCommand extends AbstractCommand { + /** + * Read Exif data from the given image + * + * Note: Windows PHP Users - in order to use this method you will need to + * enable the mbstring and exif extensions within the php.ini file. + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { if ( ! function_exists('exif_read_data')) { diff --git a/src/Intervention/Image/Commands/LineCommand.php b/src/Intervention/Image/Commands/LineCommand.php index 2c427fdc..c3e2e337 100644 --- a/src/Intervention/Image/Commands/LineCommand.php +++ b/src/Intervention/Image/Commands/LineCommand.php @@ -6,6 +6,12 @@ use \Closure; class LineCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draws line on given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $x1 = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Commands/RectangleCommand.php b/src/Intervention/Image/Commands/RectangleCommand.php index 3d0a10d2..9016162d 100644 --- a/src/Intervention/Image/Commands/RectangleCommand.php +++ b/src/Intervention/Image/Commands/RectangleCommand.php @@ -6,6 +6,12 @@ use \Closure; class RectangleCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draws rectangle on given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $x1 = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Commands/ResponseCommand.php b/src/Intervention/Image/Commands/ResponseCommand.php index 3c459f98..ee75d06d 100644 --- a/src/Intervention/Image/Commands/ResponseCommand.php +++ b/src/Intervention/Image/Commands/ResponseCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Response; class ResponseCommand extends AbstractCommand { + /** + * Builds HTTP response from given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $format = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Commands/TextCommand.php b/src/Intervention/Image/Commands/TextCommand.php index 0980e793..d91948a0 100644 --- a/src/Intervention/Image/Commands/TextCommand.php +++ b/src/Intervention/Image/Commands/TextCommand.php @@ -6,6 +6,11 @@ use \Closure; class TextCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Write text on given image + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $text = $this->argument(0)->required()->value(); diff --git a/src/Intervention/Image/Constraint.php b/src/Intervention/Image/Constraint.php index a3e79bc6..43c45b09 100644 --- a/src/Intervention/Image/Constraint.php +++ b/src/Intervention/Image/Constraint.php @@ -4,37 +4,86 @@ namespace Intervention\Image; class Constraint { + /** + * Bit value of aspect ratio constraint + */ const ASPECTRATIO = 1; + + /** + * Bit value of upsize constraint + */ const UPSIZE = 2; + /** + * Constraint size + * + * @var Intervention\Image\Size + */ private $size; + + /** + * Integer value of fixed parameters + * + * @var integer + */ private $fixed = 0; + /** + * Create a new constraint based on size + * + * @param Size $size + */ public function __construct(Size $size) { $this->size = $size; } + /** + * Returns current size of constraint + * + * @return Intervention\Image\Size + */ public function getSize() { return $this->size; } + /** + * Fix the given argument in current constraint + * @param integer $type + * @return void + */ public function fix($type) { $this->fixed = ($this->fixed & ~(1 << $type)) | (1 << $type); } + /** + * Checks if given argument is fixed in current constraint + * + * @param integer $type + * @return boolean + */ public function isFixed($type) { return (bool) ($this->fixed & (1 << $type)); } + /** + * Fixes aspect ratio in current constraint + * + * @return void + */ public function aspectRatio() { $this->fix(self::ASPECTRATIO); } + /** + * Fixes possibility to size up in current constraint + * + * @return void + */ public function upsize() { $this->fix(self::UPSIZE); diff --git a/src/Intervention/Image/File.php b/src/Intervention/Image/File.php index c354e180..f5784b99 100644 --- a/src/Intervention/Image/File.php +++ b/src/Intervention/Image/File.php @@ -4,12 +4,46 @@ namespace Intervention\Image; class File { + /** + * Mime type + * + * @var string + */ public $mime; + + /** + * Name of directory path + * + * @var string + */ public $dirname; + + /** + * Basename of current file + * + * @var string + */ public $basename; + + /** + * File extension of current file + * + * @var string + */ public $extension; + + /** + * File name of current file + * + * @var string + */ public $filename; + /** + * Sets all instance properties from given path + * + * @param string $path + */ public function setFileInfoFromPath($path) { $info = pathinfo($path); diff --git a/src/Intervention/Image/Filters/DemoFilter.php b/src/Intervention/Image/Filters/DemoFilter.php index 2a7ab86a..55100eb6 100644 --- a/src/Intervention/Image/Filters/DemoFilter.php +++ b/src/Intervention/Image/Filters/DemoFilter.php @@ -4,15 +4,34 @@ namespace Intervention\Image\Filters; class DemoFilter implements FilterInterface { + /** + * Default size of filter effects + */ const DEFAULT_SIZE = 10; + /** + * Size of filter effects + * + * @var integer + */ private $size; + /** + * Creates new instance of filter + * + * @param integer $size + */ public function __construct($size = null) { $this->size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE; } + /** + * Applies filter effects to given image + * + * @param Intervention\Image\Image $image + * @return Intervention\Image\Image + */ public function applyFilter(\Intervention\Image\Image $image) { $image->pixelate($this->size); diff --git a/src/Intervention/Image/Filters/FilterInterface.php b/src/Intervention/Image/Filters/FilterInterface.php index 4a05eb43..58f1039a 100644 --- a/src/Intervention/Image/Filters/FilterInterface.php +++ b/src/Intervention/Image/Filters/FilterInterface.php @@ -4,5 +4,11 @@ namespace Intervention\Image\Filters; interface FilterInterface { + /** + * Applies filter to given image + * + * @param Intervention\Image\Image $image + * @return Intervention\Image\Image + */ public function applyFilter(\Intervention\Image\Image $image); } diff --git a/src/Intervention/Image/Gd/Color.php b/src/Intervention/Image/Gd/Color.php index 13105435..472bafd9 100644 --- a/src/Intervention/Image/Gd/Color.php +++ b/src/Intervention/Image/Gd/Color.php @@ -6,11 +6,40 @@ use Intervention\Image\AbstractColor; class Color extends AbstractColor { + /** + * RGB Red value of current color instance + * + * @var integer + */ public $r; + + /** + * RGB Green value of current color instance + * + * @var integer + */ public $g; + + /** + * RGB Blue value of current color instance + * + * @var integer + */ public $b; + + /** + * RGB Alpha value of current color instance + * + * @var float + */ public $a; + /** + * Initiates color object from integer + * + * @param integer $value + * @return Intervention\Image\AbstractColor + */ public function initFromInteger($value) { $this->a = ($value >> 24) & 0xFF; @@ -19,6 +48,12 @@ class Color extends AbstractColor $this->b = $value & 0xFF; } + /** + * Initiates color object from given array + * + * @param array $value + * @return Intervention\Image\AbstractColor + */ public function initFromArray($array) { $array = array_values($array); @@ -42,6 +77,12 @@ class Color extends AbstractColor $this->b = $b; } + /** + * Initiates color object from given string + * + * @param string $value + * @return Intervention\Image\AbstractColor + */ public function initFromString($value) { if ($color = $this->rgbaFromString($value)) { @@ -52,6 +93,14 @@ class Color extends AbstractColor } } + /** + * Initiates color object from given R, G and B values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @return Intervention\Image\AbstractColor + */ public function initFromRgb($r, $g, $b) { $this->r = intval($r); @@ -60,6 +109,15 @@ class Color extends AbstractColor $this->a = 0; } + /** + * Initiates color object from given R, G, B and A values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @param float $a + * @return Intervention\Image\AbstractColor + */ public function initFromRgba($r, $g, $b, $a = 1) { $this->r = intval($r); @@ -68,31 +126,67 @@ class Color extends AbstractColor $this->a = $this->alpha2gd($a); } + /** + * Initiates color object from given ImagickPixel object + * + * @param ImagickPixel $value + * @return Intervention\Image\AbstractColor + */ public function initFromObject($value) { - throw new \Exception('Not available'); + throw new \Intervention\Image\Exception\NotSupportedException( + "GD colors cannot init from ImagickPixel objects." + ); } + /** + * Calculates integer value of current color instance + * + * @return integer + */ public function getInt() { return ($this->a << 24) + ($this->r << 16) + ($this->g << 8) + $this->b; } + /** + * Calculates hexadecimal value of current color instance + * + * @param string $prefix + * @return string + */ public function getHex($prefix = '') { return sprintf('%s%02x%02x%02x', $prefix, $this->r, $this->g, $this->b); } + /** + * Calculates RGB(A) in array format of current color instance + * + * @return array + */ public function getArray() { return array($this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)); } + /** + * Calculates RGBA in string format of current color instance + * + * @return string + */ public function getRgba() { return sprintf('rgba(%d, %d, %d, %.2f)', $this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)); } + /** + * Determines if current color is different from given color + * + * @param AbstractColor $color + * @param integer $tolerance + * @return boolean + */ public function differs(AbstractColor $color, $tolerance = 0) { $color_tolerance = round($tolerance * 2.55); diff --git a/src/Intervention/Image/Gd/Commands/BackupCommand.php b/src/Intervention/Image/Gd/Commands/BackupCommand.php index f8754d07..1789bf68 100644 --- a/src/Intervention/Image/Gd/Commands/BackupCommand.php +++ b/src/Intervention/Image/Gd/Commands/BackupCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class BackupCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Saves a backups of current state of image core + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { // clone current image resource diff --git a/src/Intervention/Image/Gd/Commands/BlurCommand.php b/src/Intervention/Image/Gd/Commands/BlurCommand.php index c75a0b7b..636c626a 100644 --- a/src/Intervention/Image/Gd/Commands/BlurCommand.php +++ b/src/Intervention/Image/Gd/Commands/BlurCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class BlurCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies blur effect on image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $amount = $this->argument(0)->between(0, 100)->value(1); diff --git a/src/Intervention/Image/Gd/Commands/BrightnessCommand.php b/src/Intervention/Image/Gd/Commands/BrightnessCommand.php index 2bb7abc2..e21238ec 100644 --- a/src/Intervention/Image/Gd/Commands/BrightnessCommand.php +++ b/src/Intervention/Image/Gd/Commands/BrightnessCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class BrightnessCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes image brightness + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $level = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/ColorizeCommand.php b/src/Intervention/Image/Gd/Commands/ColorizeCommand.php index 233b21e5..08307d37 100644 --- a/src/Intervention/Image/Gd/Commands/ColorizeCommand.php +++ b/src/Intervention/Image/Gd/Commands/ColorizeCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class ColorizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes balance of different RGB color channels + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $red = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/ContrastCommand.php b/src/Intervention/Image/Gd/Commands/ContrastCommand.php index 81083550..e604f002 100644 --- a/src/Intervention/Image/Gd/Commands/ContrastCommand.php +++ b/src/Intervention/Image/Gd/Commands/ContrastCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class ContrastCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes contrast of image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $level = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/CropCommand.php b/src/Intervention/Image/Gd/Commands/CropCommand.php index 8d03cb2e..a770470c 100644 --- a/src/Intervention/Image/Gd/Commands/CropCommand.php +++ b/src/Intervention/Image/Gd/Commands/CropCommand.php @@ -7,6 +7,12 @@ use \Intervention\Image\Size; class CropCommand extends ResizeCommand { + /** + * Crop an image instance + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/DestroyCommand.php b/src/Intervention/Image/Gd/Commands/DestroyCommand.php index 075f5bdf..3d38c3bd 100644 --- a/src/Intervention/Image/Gd/Commands/DestroyCommand.php +++ b/src/Intervention/Image/Gd/Commands/DestroyCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class DestroyCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Destroys current image core and frees up memory + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return imagedestroy($image->getCore()); diff --git a/src/Intervention/Image/Gd/Commands/FillCommand.php b/src/Intervention/Image/Gd/Commands/FillCommand.php index c02239c3..35df75ff 100644 --- a/src/Intervention/Image/Gd/Commands/FillCommand.php +++ b/src/Intervention/Image/Gd/Commands/FillCommand.php @@ -7,6 +7,12 @@ use Intervention\Image\Gd\Color; class FillCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Fills image with color or pattern + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $filling = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Gd/Commands/FitCommand.php b/src/Intervention/Image/Gd/Commands/FitCommand.php index fd4d4993..1968d595 100644 --- a/src/Intervention/Image/Gd/Commands/FitCommand.php +++ b/src/Intervention/Image/Gd/Commands/FitCommand.php @@ -7,9 +7,15 @@ use \Intervention\Image\Size; class FitCommand extends ResizeCommand { + /** + * Crops and resized an image at the same time + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { - $width = $this->argument(0)->type('integer')->value(); + $width = $this->argument(0)->type('integer')->required()->value(); $height = $this->argument(1)->type('integer')->value($width); // calculate size diff --git a/src/Intervention/Image/Gd/Commands/FlipCommand.php b/src/Intervention/Image/Gd/Commands/FlipCommand.php index a1e1da84..81f73d5d 100644 --- a/src/Intervention/Image/Gd/Commands/FlipCommand.php +++ b/src/Intervention/Image/Gd/Commands/FlipCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class FlipCommand extends ResizeCommand { + /** + * Mirrors an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mode = $this->argument(0)->value('h'); diff --git a/src/Intervention/Image/Gd/Commands/GammaCommand.php b/src/Intervention/Image/Gd/Commands/GammaCommand.php index d77ce4b2..c1c5526d 100644 --- a/src/Intervention/Image/Gd/Commands/GammaCommand.php +++ b/src/Intervention/Image/Gd/Commands/GammaCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class GammaCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies gamma correction to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $gamma = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/GetSizeCommand.php b/src/Intervention/Image/Gd/Commands/GetSizeCommand.php index d2d36957..095eb5d1 100644 --- a/src/Intervention/Image/Gd/Commands/GetSizeCommand.php +++ b/src/Intervention/Image/Gd/Commands/GetSizeCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Size; class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Reads size of given image instance in pixels + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $this->setOutput(new Size( diff --git a/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php b/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php index 70f15f92..9675107e 100644 --- a/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php +++ b/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class GreyscaleCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Turns an image into a greyscale version + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return imagefilter($image->getCore(), IMG_FILTER_GRAYSCALE); diff --git a/src/Intervention/Image/Gd/Commands/HeightenCommand.php b/src/Intervention/Image/Gd/Commands/HeightenCommand.php index 4f3900ac..132664d5 100644 --- a/src/Intervention/Image/Gd/Commands/HeightenCommand.php +++ b/src/Intervention/Image/Gd/Commands/HeightenCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class HeightenCommand extends ResizeCommand { + /** + * Resize image proportionally to given height + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $height = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/InsertCommand.php b/src/Intervention/Image/Gd/Commands/InsertCommand.php index 7cbe1c08..5a34561b 100644 --- a/src/Intervention/Image/Gd/Commands/InsertCommand.php +++ b/src/Intervention/Image/Gd/Commands/InsertCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class InsertCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Insert another image into given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $source = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Gd/Commands/InterlaceCommand.php b/src/Intervention/Image/Gd/Commands/InterlaceCommand.php index e23bbeb1..efffde5e 100644 --- a/src/Intervention/Image/Gd/Commands/InterlaceCommand.php +++ b/src/Intervention/Image/Gd/Commands/InterlaceCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class InterlaceCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Toggles interlaced encoding mode + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mode = $this->argument(0)->type('bool')->value(true); diff --git a/src/Intervention/Image/Gd/Commands/InvertCommand.php b/src/Intervention/Image/Gd/Commands/InvertCommand.php index 0aa3e5dd..34fb8802 100644 --- a/src/Intervention/Image/Gd/Commands/InvertCommand.php +++ b/src/Intervention/Image/Gd/Commands/InvertCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class InvertCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Inverts colors of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return imagefilter($image->getCore(), IMG_FILTER_NEGATE); diff --git a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php index d4efb2e5..91b37b70 100644 --- a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php +++ b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php @@ -6,6 +6,12 @@ use Intervention\Image\Gd\Color; class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Reduces colors of a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $count = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Gd/Commands/MaskCommand.php b/src/Intervention/Image/Gd/Commands/MaskCommand.php index eff46885..2f314ea6 100644 --- a/src/Intervention/Image/Gd/Commands/MaskCommand.php +++ b/src/Intervention/Image/Gd/Commands/MaskCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class MaskCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies an alpha mask to an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mask_source = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Gd/Commands/OpacityCommand.php b/src/Intervention/Image/Gd/Commands/OpacityCommand.php index bdd271a6..54fa2fe6 100644 --- a/src/Intervention/Image/Gd/Commands/OpacityCommand.php +++ b/src/Intervention/Image/Gd/Commands/OpacityCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Defines opacity of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $transparency = $this->argument(0)->between(0, 100)->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/PickColorCommand.php b/src/Intervention/Image/Gd/Commands/PickColorCommand.php index b18a4a21..b5233d80 100644 --- a/src/Intervention/Image/Gd/Commands/PickColorCommand.php +++ b/src/Intervention/Image/Gd/Commands/PickColorCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Gd\Color; class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Read color information from a certain position + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $x = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/PixelCommand.php b/src/Intervention/Image/Gd/Commands/PixelCommand.php index b83c5023..f4039392 100644 --- a/src/Intervention/Image/Gd/Commands/PixelCommand.php +++ b/src/Intervention/Image/Gd/Commands/PixelCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Gd\Color; class PixelCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draws one pixel to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $color = $this->argument(0)->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/PixelateCommand.php b/src/Intervention/Image/Gd/Commands/PixelateCommand.php index 9f634bac..76cf902d 100644 --- a/src/Intervention/Image/Gd/Commands/PixelateCommand.php +++ b/src/Intervention/Image/Gd/Commands/PixelateCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies a pixelation effect to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $size = $this->argument(0)->type('integer')->value(10); diff --git a/src/Intervention/Image/Gd/Commands/ResetCommand.php b/src/Intervention/Image/Gd/Commands/ResetCommand.php index c3d34b31..5da7a5e3 100644 --- a/src/Intervention/Image/Gd/Commands/ResetCommand.php +++ b/src/Intervention/Image/Gd/Commands/ResetCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class ResetCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resets given image to its backup state + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { if (is_resource($backup = $image->getBackup())) { diff --git a/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php b/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php index a5792931..bb951c97 100644 --- a/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php +++ b/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php @@ -7,6 +7,12 @@ use \Intervention\Image\Size; class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resizes image boundaries + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/ResizeCommand.php b/src/Intervention/Image/Gd/Commands/ResizeCommand.php index 5903f78e..fce2d783 100644 --- a/src/Intervention/Image/Gd/Commands/ResizeCommand.php +++ b/src/Intervention/Image/Gd/Commands/ResizeCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resizes image dimensions + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Gd/Commands/RotateCommand.php b/src/Intervention/Image/Gd/Commands/RotateCommand.php index 06c66fdc..6cadd742 100644 --- a/src/Intervention/Image/Gd/Commands/RotateCommand.php +++ b/src/Intervention/Image/Gd/Commands/RotateCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Gd\Color; class RotateCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Rotates image counter clockwise + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $angle = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Gd/Commands/TrimCommand.php b/src/Intervention/Image/Gd/Commands/TrimCommand.php index b6b70304..ed9d7c32 100644 --- a/src/Intervention/Image/Gd/Commands/TrimCommand.php +++ b/src/Intervention/Image/Gd/Commands/TrimCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Color; class TrimCommand extends ResizeCommand { + /** + * Trims away parts of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $base = $this->argument(0)->type('string')->value(); diff --git a/src/Intervention/Image/Gd/Commands/WidenCommand.php b/src/Intervention/Image/Gd/Commands/WidenCommand.php index e30eca31..815bdfd3 100644 --- a/src/Intervention/Image/Gd/Commands/WidenCommand.php +++ b/src/Intervention/Image/Gd/Commands/WidenCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Gd\Commands; class WidenCommand extends ResizeCommand { + /** + * Resize image proportionally to given width + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Gd/Driver.php b/src/Intervention/Image/Gd/Driver.php index f8e119db..568b9557 100644 --- a/src/Intervention/Image/Gd/Driver.php +++ b/src/Intervention/Image/Gd/Driver.php @@ -6,15 +6,26 @@ use \Intervention\Image\Size; class Driver extends \Intervention\Image\AbstractDriver { - public $source; - public $encoder; - + /** + * Creates new instance of driver + * + * @param Intervention\Image\Gd\Source $source + * @param Intervention\Image\Gd\Encoder $encoder + */ public function __construct(Source $source = null, Encoder $encoder = null) { $this->source = $source ? $source : new Source; $this->encoder = $encoder ? $encoder : new Encoder; } + /** + * Creates new image instance + * + * @param integer $width + * @param integer $height + * @param string $background + * @return Intervention\Image\Image + */ public function newImage($width, $height, $background = null) { // create empty resource @@ -29,6 +40,12 @@ class Driver extends \Intervention\Image\AbstractDriver return $image; } + /** + * Reads given string into color object + * + * @param string $value + * @return AbstractColor + */ public function parseColor($value) { return new Color($value); diff --git a/src/Intervention/Image/Gd/Encoder.php b/src/Intervention/Image/Gd/Encoder.php index 5bcb9c8f..c1efb03c 100644 --- a/src/Intervention/Image/Gd/Encoder.php +++ b/src/Intervention/Image/Gd/Encoder.php @@ -4,6 +4,11 @@ namespace Intervention\Image\Gd; class Encoder extends \Intervention\Image\AbstractEncoder { + /** + * Processes and returns encoded image as JPEG string + * + * @return string + */ protected function processJpeg() { ob_start(); @@ -15,6 +20,11 @@ class Encoder extends \Intervention\Image\AbstractEncoder return $buffer; } + /** + * Processes and returns encoded image as PNG string + * + * @return string + */ protected function processPng() { ob_start(); @@ -29,6 +39,11 @@ class Encoder extends \Intervention\Image\AbstractEncoder return $buffer; } + /** + * Processes and returns encoded image as GIF string + * + * @return string + */ protected function processGif() { ob_start(); diff --git a/src/Intervention/Image/Gd/Font.php b/src/Intervention/Image/Gd/Font.php index cf6e9460..69852a85 100644 --- a/src/Intervention/Image/Gd/Font.php +++ b/src/Intervention/Image/Gd/Font.php @@ -171,6 +171,7 @@ class Font extends \Intervention\Image\AbstractFont /** * Draws font to given image at given position + * * @param Image $image * @param integer $posx * @param integer $posy diff --git a/src/Intervention/Image/Gd/Shapes/CircleShape.php b/src/Intervention/Image/Gd/Shapes/CircleShape.php index 8a6b5cd8..1383ad26 100644 --- a/src/Intervention/Image/Gd/Shapes/CircleShape.php +++ b/src/Intervention/Image/Gd/Shapes/CircleShape.php @@ -6,8 +6,18 @@ use \Intervention\Image\Image; class CircleShape extends EllipseShape { + /** + * Radius of circle in pixels + * + * @var integer + */ public $radius = 100; + /** + * Create new instance of circle + * + * @param integer $radius + */ function __construct($radius = null) { $this->width = is_numeric($radius) ? intval($radius) : $this->radius; @@ -15,6 +25,14 @@ class CircleShape extends EllipseShape $this->radius = is_numeric($radius) ? intval($radius) : $this->radius; } + /** + * Draw current circle on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { return parent::applyToImage($image, $x, $y); diff --git a/src/Intervention/Image/Gd/Shapes/EllipseShape.php b/src/Intervention/Image/Gd/Shapes/EllipseShape.php index 008e81c6..35b29134 100644 --- a/src/Intervention/Image/Gd/Shapes/EllipseShape.php +++ b/src/Intervention/Image/Gd/Shapes/EllipseShape.php @@ -7,15 +7,40 @@ use \Intervention\Image\Gd\Color; class EllipseShape extends \Intervention\Image\AbstractShape { + /** + * Width of ellipse in pixels + * + * @var integer + */ public $width = 100; + + /** + * Height of ellipse in pixels + * + * @var integer + */ public $height = 100; + /** + * Create new ellipse instance + * + * @param integer $width + * @param integer $height + */ function __construct($width = null, $height = null) { $this->width = is_numeric($width) ? intval($width) : $this->width; $this->height = is_numeric($height) ? intval($height) : $this->height; } + /** + * Draw ellipse instance on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $background = new Color($this->background); diff --git a/src/Intervention/Image/Gd/Shapes/LineShape.php b/src/Intervention/Image/Gd/Shapes/LineShape.php index 9d833aae..3e32055c 100644 --- a/src/Intervention/Image/Gd/Shapes/LineShape.php +++ b/src/Intervention/Image/Gd/Shapes/LineShape.php @@ -7,22 +7,63 @@ use \Intervention\Image\Gd\Color; class LineShape extends \Intervention\Image\AbstractShape { + /** + * Starting point x-coordinate of line + * + * @var integer + */ public $x = 0; + + /** + * Starting point y-coordinate of line + * + * @var integer + */ public $y = 0; + + /** + * Color of line + * + * @var string + */ public $color = '#000000'; + + /** + * Width of line in pixels + * + * @var integer + */ public $width = 1; + /** + * Create new line shape instance + * + * @param integer $x + * @param integer $y + */ function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : $this->x; $this->y = is_numeric($y) ? intval($y) : $this->y; } + /** + * Set current line color + * + * @param string $color + * @return void + */ public function color($color) { $this->color = $color; } + /** + * Set current line width in pixels + * + * @param integer $width + * @return void + */ public function width($width) { throw new \Intervention\Image\Exception\NotSupportedException( @@ -30,6 +71,14 @@ class LineShape extends \Intervention\Image\AbstractShape ); } + /** + * Draw current instance of line to given endpoint on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $color = new Color($this->color); diff --git a/src/Intervention/Image/Gd/Shapes/RectangleShape.php b/src/Intervention/Image/Gd/Shapes/RectangleShape.php index ba7c4aaa..ad780113 100644 --- a/src/Intervention/Image/Gd/Shapes/RectangleShape.php +++ b/src/Intervention/Image/Gd/Shapes/RectangleShape.php @@ -7,11 +7,42 @@ use \Intervention\Image\Gd\Color; class RectangleShape extends \Intervention\Image\AbstractShape { + /** + * X-Coordinate of top-left point + * + * @var integer + */ public $x1 = 0; + + /** + * Y-Coordinate of top-left point + * + * @var integer + */ public $y1 = 0; + + /** + * X-Coordinate of bottom-right point + * + * @var integer + */ public $x2 = 0; + + /** + * Y-Coordinate of bottom-right point + * + * @var integer + */ public $y2 = 0; + /** + * Create new rectangle shape instance + * + * @param integer $x1 + * @param integer $y1 + * @param integer $x2 + * @param integer $y2 + */ function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) { $this->x1 = is_numeric($x1) ? intval($x1) : $this->x1; @@ -20,6 +51,14 @@ class RectangleShape extends \Intervention\Image\AbstractShape $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2; } + /** + * Draw rectangle to given image at certain position + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $background = new Color($this->background); diff --git a/src/Intervention/Image/Gd/Source.php b/src/Intervention/Image/Gd/Source.php index dee22615..8cba903f 100644 --- a/src/Intervention/Image/Gd/Source.php +++ b/src/Intervention/Image/Gd/Source.php @@ -7,6 +7,12 @@ use \Intervention\Image\Size; class Source extends \Intervention\Image\AbstractSource { + /** + * Initiates new image from path in filesystem + * + * @param string $path + * @return Intervention\Image\Image + */ public function initFromPath($path) { $info = @getimagesize($path); @@ -50,18 +56,36 @@ class Source extends \Intervention\Image\AbstractSource return $image; } + /** + * Initiates new image from GD resource + * + * @param Resource $resource + * @return Intervention\Image\Image + */ public function initFromGdResource($resource) { return new Image(new Driver, $resource); } - public function initFromImagick($object) + /** + * Initiates new image from Imagick object + * + * @param Imagick $object + * @return Intervention\Image\Image + */ + public function initFromImagick(\Imagick $object) { throw new \Intervention\Image\Exception\NotSupportedException( "Gd driver is unable to init from Imagick object." ); } + /** + * Initiates new image from binary data + * + * @param string $data + * @return Intervention\Image\Image + */ public function initFromBinary($binary) { $resource = @imagecreatefromstring($binary); diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index db91b486..a46e3e7b 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -4,28 +4,79 @@ namespace Intervention\Image; class Image extends File { + /** + * Instance of current image driver + * + * @var Intervention\Image\AbstractDriver + */ protected $driver; + + /** + * Image resource/object of current image processor + * + * @var mixed + */ protected $core; + + /** + * Image resource backup of current image processor + * + * @var mixded + */ protected $backup; + + /** + * Last image encoding result + * + * @var string + */ public $encoded = ''; + /** + * Creates a new Image instance + * + * @param Driver $driver + * @param mixed $core + */ public function __construct($driver = null, $core = null) { $this->driver = $driver; $this->core = $core; } + /** + * Magic method to catch all image calls + * usually any AbstractCommand + * + * @param string $name + * @param Array $arguments + * @return mixed + */ public function __call($name, $arguments) { $command = $this->driver->executeCommand($this, $name, $arguments); return $command->hasOutput() ? $command->getOutput() : $this; } + /** + * Starts encoding of current image + * + * @param string $format + * @param integer $quality + * @return Intervention\Image\Image + */ public function encode($format = null, $quality = 90) { return $this->driver->encode($this, $format, $quality); } + /** + * Saves encoded image in filesystem + * + * @param string $path + * @param integer $quality + * @return Intervention\Image\Image + */ public function save($path = null, $quality = null) { $path = is_null($path) ? ($this->dirname .'/'. $this->basename) : $path; @@ -44,28 +95,53 @@ class Image extends File return $this; } + /** + * Runs a given filter on current image + * + * @param FiltersFilterInterface $filter + * @return Intervention\Image\Image + */ public function filter(Filters\FilterInterface $filter) { return $filter->applyFilter($this); } + /** + * Returns current image driver + * + * @return Intervention\Image\AbstractDriver + */ public function getDriver() { return $this->driver; } - public function setDriver($driver) + /** + * Sets current image driver + * @param AbstractDriver $driver + */ + public function setDriver(AbstractDriver $driver) { $this->driver = $driver; return $this; } + /** + * Returns current image resource/obj + * + * @return mixed + */ public function getCore() { return $this->core; } + /** + * Sets current image resource + * + * @param mixed $core + */ public function setCore($core) { $this->core = $core; @@ -73,11 +149,21 @@ class Image extends File return $this; } + /** + * Returns current image backup + * + * @return mixed + */ public function getBackup() { return $this->backup; } + /** + * Sets current image backup + * + * @param mixed $value + */ public function setBackup($value) { $this->backup = $value; @@ -85,16 +171,31 @@ class Image extends File return $this; } + /** + * Checks if current image is already encoded + * + * @return boolean + */ public function isEncoded() { return ! is_null($this->encoded); } + /** + * Returns encoded image data of current image + * + * @return string + */ public function getEncoded() { return $this->encoded; } + /** + * Sets encoded image buffer + * + * @param string $value + */ public function setEncoded($value) { $this->encoded = $value; @@ -102,16 +203,31 @@ class Image extends File return $this; } + /** + * Calculates current image width + * + * @return integer + */ public function getWidth() { return $this->getSize()->width; } + /** + * Calculates current image height + * + * @return integer + */ public function getHeight() { return $this->getSize()->height; } + /** + * Returns encoded image data in string conversion + * + * @return string + */ public function __toString() { return $this->encoded; diff --git a/src/Intervention/Image/ImageManager.php b/src/Intervention/Image/ImageManager.php index 600706d6..60b0e4ce 100644 --- a/src/Intervention/Image/ImageManager.php +++ b/src/Intervention/Image/ImageManager.php @@ -8,8 +8,18 @@ use Illuminate\Filesystem\Filesystem; class ImageManager { + /** + * Instance of Illuminate Config respository + * + * @var Illuminate\Config\Repository + */ public $config; + /** + * Creates new instance of Image Manager + * + * @param Illuminate\Config\Repository $config + */ public function __construct(\Illuminate\Config\Repository $config = null) { // create configurator @@ -29,6 +39,11 @@ class ImageManager } } + /** + * Creates a driver instance according to config settings + * + * @return Intervention\Image\AbstractDriver + */ private function createDriver() { $drivername = ucfirst($this->config->get('image::driver')); @@ -43,11 +58,25 @@ class ImageManager ); } + /** + * Initiates an Image instance from different input types + * + * @param mixed $data + * @return Intervention\Image\Image + */ public function make($data) { return $this->createDriver()->init($data); } + /** + * Creates an empty image canvas + * + * @param integer $width + * @param integer $height + * @param mixed $background + * @return Intervention\Image\Image + */ public function canvas($width, $height, $background = null) { return $this->createDriver()->newImage($width, $height, $background); diff --git a/src/Intervention/Image/ImageManagerStatic.php b/src/Intervention/Image/ImageManagerStatic.php index d4b85e7a..0cf20f87 100644 --- a/src/Intervention/Image/ImageManagerStatic.php +++ b/src/Intervention/Image/ImageManagerStatic.php @@ -4,23 +4,52 @@ namespace Intervention\Image; class ImageManagerStatic { + /** + * Instance of Intervention\Image\ImageManager + * + * @var Intervention\Image\ImageManager + */ public $manager; + /** + * Creates a new instance + * + * @param Intervention\Image\ImageManager $manager + */ public function __construct(ImageManager $manager = null) { $this->manager = $manager ? $manager : new ImageManager; } + /** + * Creates a new instance + * + * @return Intervention\Image\ImageManagerStatic + */ public static function newInstance() { return new self; } + /** + * Statically initiates an Image instance from different input types + * + * @param mixed $data + * @return Intervention\Image\Image + */ public static function make($data) { return self::newInstance()->manager->make($data); } + /** + * Statically creates an empty image canvas + * + * @param integer $width + * @param integer $height + * @param mixed $background + * @return Intervention\Image\Image + */ public static function canvas($width, $height, $background = null) { return self::newInstance()->manager->canvas($width, $height, $background); diff --git a/src/Intervention/Image/Imagick/Color.php b/src/Intervention/Image/Imagick/Color.php index f24b9336..c558a038 100644 --- a/src/Intervention/Image/Imagick/Color.php +++ b/src/Intervention/Image/Imagick/Color.php @@ -4,8 +4,19 @@ namespace Intervention\Image\Imagick; class Color extends \Intervention\Image\AbstractColor { + /** + * ImagickPixel containing current color information + * + * @var ImagickPixel + */ public $pixel; + /** + * Initiates color object from integer + * + * @param integer $value + * @return Intervention\Image\AbstractColor + */ public function initFromInteger($value) { $a = ($value >> 24) & 0xFF; @@ -17,6 +28,12 @@ class Color extends \Intervention\Image\AbstractColor $this->setPixel($r, $g, $b, $a); } + /** + * Initiates color object from given array + * + * @param array $value + * @return Intervention\Image\AbstractColor + */ public function initFromArray($array) { $array = array_values($array); @@ -36,6 +53,12 @@ class Color extends \Intervention\Image\AbstractColor $this->setPixel($r, $g, $b, $a); } + /** + * Initiates color object from given string + * + * @param string $value + * @return Intervention\Image\AbstractColor + */ public function initFromString($value) { if ($color = $this->rgbaFromString($value)) { @@ -43,6 +66,12 @@ class Color extends \Intervention\Image\AbstractColor } } + /** + * Initiates color object from given ImagickPixel object + * + * @param ImagickPixel $value + * @return Intervention\Image\AbstractColor + */ public function initFromObject($value) { if (is_a($value, '\ImagickPixel')) { @@ -50,16 +79,38 @@ class Color extends \Intervention\Image\AbstractColor } } + /** + * Initiates color object from given R, G and B values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @return Intervention\Image\AbstractColor + */ public function initFromRgb($r, $g, $b) { $this->setPixel($r, $g, $b); } + /** + * Initiates color object from given R, G, B and A values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @param float $a + * @return Intervention\Image\AbstractColor + */ public function initFromRgba($r, $g, $b, $a) { $this->setPixel($r, $g, $b, $a); } + /** + * Calculates integer value of current color instance + * + * @return integer + */ public function getInt() { $r = $this->getRedValue(); @@ -70,6 +121,12 @@ class Color extends \Intervention\Image\AbstractColor return intval(($a << 24) + ($r << 16) + ($g << 8) + $b); } + /** + * Calculates hexadecimal value of current color instance + * + * @param string $prefix + * @return string + */ public function getHex($prefix = '') { return sprintf('%s%02x%02x%02x', $prefix, @@ -79,6 +136,11 @@ class Color extends \Intervention\Image\AbstractColor ); } + /** + * Calculates RGB(A) in array format of current color instance + * + * @return array + */ public function getArray() { return array( @@ -89,6 +151,11 @@ class Color extends \Intervention\Image\AbstractColor ); } + /** + * Calculates RGBA in string format of current color instance + * + * @return string + */ public function getRgba() { return sprintf('rgba(%d, %d, %d, %.2f)', @@ -99,6 +166,13 @@ class Color extends \Intervention\Image\AbstractColor ); } + /** + * Determines if current color is different from given color + * + * @param AbstractColor $color + * @param integer $tolerance + * @return boolean + */ public function differs(\Intervention\Image\AbstractColor $color, $tolerance = 0) { $color_tolerance = round($tolerance * 2.55); @@ -119,26 +193,51 @@ class Color extends \Intervention\Image\AbstractColor ); } + /** + * Returns RGB red value of current color + * + * @return integer + */ public function getRedValue() { return intval(round($this->pixel->getColorValue(\Imagick::COLOR_RED) * 255)); } + /** + * Returns RGB green value of current color + * + * @return integer + */ public function getGreenValue() { return intval(round($this->pixel->getColorValue(\Imagick::COLOR_GREEN) * 255)); } + /** + * Returns RGB blue value of current color + * + * @return integer + */ public function getBlueValue() { return intval(round($this->pixel->getColorValue(\Imagick::COLOR_BLUE) * 255)); } + /** + * Returns RGB alpha value of current color + * + * @return float + */ public function getAlphaValue() { return round($this->pixel->getColorValue(\Imagick::COLOR_ALPHA), 2); } + /** + * Initiates ImagickPixel from given RGBA values + * + * @return ImagickPixel + */ private function setPixel($r, $g, $b, $a = null) { $a = is_null($a) ? 1 : $a; @@ -148,11 +247,22 @@ class Color extends \Intervention\Image\AbstractColor ); } + /** + * Returns current color as ImagickPixel + * + * @return ImagickPixel + */ public function getPixel() { return $this->pixel; } + /** + * Calculates RGA integer alpha value into float value + * + * @param integer $value + * @return float + */ private function rgb2alpha($value) { // (255 -> 1.0) / (0 -> 0.0) diff --git a/src/Intervention/Image/Imagick/Commands/BackupCommand.php b/src/Intervention/Image/Imagick/Commands/BackupCommand.php index 2cb05e3d..6b04b2b8 100644 --- a/src/Intervention/Image/Imagick/Commands/BackupCommand.php +++ b/src/Intervention/Image/Imagick/Commands/BackupCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class BackupCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Saves a backups of current state of image core + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { // clone current image resource diff --git a/src/Intervention/Image/Imagick/Commands/BlurCommand.php b/src/Intervention/Image/Imagick/Commands/BlurCommand.php index 2ccfc6ab..c0e7e743 100644 --- a/src/Intervention/Image/Imagick/Commands/BlurCommand.php +++ b/src/Intervention/Image/Imagick/Commands/BlurCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class BlurCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies blur effect on image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $amount = $this->argument(0)->between(0, 100)->value(1); diff --git a/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php b/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php index 6b39098e..23b3572b 100644 --- a/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php +++ b/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class BrightnessCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes image brightness + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $level = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php b/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php index 06da30b3..b1bba4d8 100644 --- a/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class ColorizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes balance of different RGB color channels + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $red = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/ContrastCommand.php b/src/Intervention/Image/Imagick/Commands/ContrastCommand.php index 2c281b72..41e54869 100644 --- a/src/Intervention/Image/Imagick/Commands/ContrastCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ContrastCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class ContrastCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Changes contrast of image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $level = $this->argument(0)->between(-100, 100)->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/CropCommand.php b/src/Intervention/Image/Imagick/Commands/CropCommand.php index 22583e4a..ab3e3dae 100644 --- a/src/Intervention/Image/Imagick/Commands/CropCommand.php +++ b/src/Intervention/Image/Imagick/Commands/CropCommand.php @@ -7,6 +7,12 @@ use \Intervention\Image\Size; class CropCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Crop an image instance + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/DestroyCommand.php b/src/Intervention/Image/Imagick/Commands/DestroyCommand.php index 06cf16f6..dd112b21 100644 --- a/src/Intervention/Image/Imagick/Commands/DestroyCommand.php +++ b/src/Intervention/Image/Imagick/Commands/DestroyCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class DestroyCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Destroys current image core and frees up memory + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return $image->getCore()->clear(); diff --git a/src/Intervention/Image/Imagick/Commands/FillCommand.php b/src/Intervention/Image/Imagick/Commands/FillCommand.php index ccc16f20..5ed4caf6 100644 --- a/src/Intervention/Image/Imagick/Commands/FillCommand.php +++ b/src/Intervention/Image/Imagick/Commands/FillCommand.php @@ -8,6 +8,12 @@ use \Intervention\Image\Imagick\Color; class FillCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Fills image with color or pattern + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $filling = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Imagick/Commands/FitCommand.php b/src/Intervention/Image/Imagick/Commands/FitCommand.php index ae0208e6..5dd01d91 100644 --- a/src/Intervention/Image/Imagick/Commands/FitCommand.php +++ b/src/Intervention/Image/Imagick/Commands/FitCommand.php @@ -6,9 +6,15 @@ use \Intervention\Image\Size; class FitCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Crops and resized an image at the same time + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { - $width = $this->argument(0)->type('integer')->value(); + $width = $this->argument(0)->type('integer')->required()->value(); $height = $this->argument(1)->type('integer')->value($width); // calculate size diff --git a/src/Intervention/Image/Imagick/Commands/FlipCommand.php b/src/Intervention/Image/Imagick/Commands/FlipCommand.php index 107d12bd..0372869f 100644 --- a/src/Intervention/Image/Imagick/Commands/FlipCommand.php +++ b/src/Intervention/Image/Imagick/Commands/FlipCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class FlipCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Mirrors an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mode = $this->argument(0)->value('h'); diff --git a/src/Intervention/Image/Imagick/Commands/GammaCommand.php b/src/Intervention/Image/Imagick/Commands/GammaCommand.php index 5065ffe7..b5d74f9d 100644 --- a/src/Intervention/Image/Imagick/Commands/GammaCommand.php +++ b/src/Intervention/Image/Imagick/Commands/GammaCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class GammaCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies gamma correction to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $gamma = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php index a5f8bde6..d89b2c68 100644 --- a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php +++ b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Size; class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Reads size of given image instance in pixels + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $info = $image->getCore()->identifyImage(true); diff --git a/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php b/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php index 6c717e49..2a306b6e 100644 --- a/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php +++ b/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class GreyscaleCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Turns an image into a greyscale version + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return $image->getCore()->modulateImage(100, 0, 100); diff --git a/src/Intervention/Image/Imagick/Commands/HeightenCommand.php b/src/Intervention/Image/Imagick/Commands/HeightenCommand.php index 98646d71..adaf8e5e 100644 --- a/src/Intervention/Image/Imagick/Commands/HeightenCommand.php +++ b/src/Intervention/Image/Imagick/Commands/HeightenCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class HeightenCommand extends ResizeCommand { + /** + * Resize image proportionally to given height + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $height = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/InsertCommand.php b/src/Intervention/Image/Imagick/Commands/InsertCommand.php index 4ea21c8e..1d23a7a1 100644 --- a/src/Intervention/Image/Imagick/Commands/InsertCommand.php +++ b/src/Intervention/Image/Imagick/Commands/InsertCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Imagick\Source; class InsertCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Insert another image into given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $source = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php b/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php index 3af269d7..7ed86108 100644 --- a/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php +++ b/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class InterlaceCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Toggles interlaced encoding mode + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mode = $this->argument(0)->type('bool')->value(true); diff --git a/src/Intervention/Image/Imagick/Commands/InvertCommand.php b/src/Intervention/Image/Imagick/Commands/InvertCommand.php index 0c877d2d..21a99eb4 100644 --- a/src/Intervention/Image/Imagick/Commands/InvertCommand.php +++ b/src/Intervention/Image/Imagick/Commands/InvertCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class InvertCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Inverts colors of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { return $image->getCore()->negateImage(false); diff --git a/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php b/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php index 05f4457e..85e8967b 100644 --- a/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php +++ b/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Reduces colors of a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $count = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Imagick/Commands/MaskCommand.php b/src/Intervention/Image/Imagick/Commands/MaskCommand.php index f4f6b667..7f6986c3 100644 --- a/src/Intervention/Image/Imagick/Commands/MaskCommand.php +++ b/src/Intervention/Image/Imagick/Commands/MaskCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class MaskCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies an alpha mask to an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $mask_source = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Imagick/Commands/OpacityCommand.php b/src/Intervention/Image/Imagick/Commands/OpacityCommand.php index 7d5b029b..994cd1b5 100644 --- a/src/Intervention/Image/Imagick/Commands/OpacityCommand.php +++ b/src/Intervention/Image/Imagick/Commands/OpacityCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Defines opacity of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $transparency = $this->argument(0)->between(0, 100)->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/PickColorCommand.php b/src/Intervention/Image/Imagick/Commands/PickColorCommand.php index 9b157b4a..e00ed3bb 100644 --- a/src/Intervention/Image/Imagick/Commands/PickColorCommand.php +++ b/src/Intervention/Image/Imagick/Commands/PickColorCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Imagick\Color; class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Read color information from a certain position + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $x = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/PixelCommand.php b/src/Intervention/Image/Imagick/Commands/PixelCommand.php index c4e942b4..924a8fd6 100644 --- a/src/Intervention/Image/Imagick/Commands/PixelCommand.php +++ b/src/Intervention/Image/Imagick/Commands/PixelCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Imagick\Color; class PixelCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Draws one pixel to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $color = $this->argument(0)->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/PixelateCommand.php b/src/Intervention/Image/Imagick/Commands/PixelateCommand.php index 85f86f81..c575d5ce 100644 --- a/src/Intervention/Image/Imagick/Commands/PixelateCommand.php +++ b/src/Intervention/Image/Imagick/Commands/PixelateCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Applies a pixelation effect to a given image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $size = $this->argument(0)->type('integer')->value(10); diff --git a/src/Intervention/Image/Imagick/Commands/ResetCommand.php b/src/Intervention/Image/Imagick/Commands/ResetCommand.php index 8457112f..5094e943 100644 --- a/src/Intervention/Image/Imagick/Commands/ResetCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ResetCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class ResetCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resets given image to its backup state + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $backup = $image->getBackup(); diff --git a/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php b/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php index 26f0a0ee..21d9269b 100644 --- a/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resizes image boundaries + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/ResizeCommand.php b/src/Intervention/Image/Imagick/Commands/ResizeCommand.php index 6357c6ed..1a40cedc 100644 --- a/src/Intervention/Image/Imagick/Commands/ResizeCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ResizeCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Resizes image dimensions + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->value(); diff --git a/src/Intervention/Image/Imagick/Commands/RotateCommand.php b/src/Intervention/Image/Imagick/Commands/RotateCommand.php index 6b1c7856..8d4ab336 100644 --- a/src/Intervention/Image/Imagick/Commands/RotateCommand.php +++ b/src/Intervention/Image/Imagick/Commands/RotateCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Imagick\Color; class RotateCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Rotates image counter clockwise + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $angle = $this->argument(0)->type('numeric')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Commands/TrimCommand.php b/src/Intervention/Image/Imagick/Commands/TrimCommand.php index 3f6229f9..3cf4e08b 100644 --- a/src/Intervention/Image/Imagick/Commands/TrimCommand.php +++ b/src/Intervention/Image/Imagick/Commands/TrimCommand.php @@ -6,6 +6,12 @@ use \Intervention\Image\Imagick\Color; class TrimCommand extends \Intervention\Image\Commands\AbstractCommand { + /** + * Trims away parts of an image + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $base = $this->argument(0)->type('string')->value(); diff --git a/src/Intervention/Image/Imagick/Commands/WidenCommand.php b/src/Intervention/Image/Imagick/Commands/WidenCommand.php index c26134e4..954c2205 100644 --- a/src/Intervention/Image/Imagick/Commands/WidenCommand.php +++ b/src/Intervention/Image/Imagick/Commands/WidenCommand.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Imagick\Commands; class WidenCommand extends ResizeCommand { + /** + * Resize image proportionally to given width + * + * @param Intervention\Image\Image $image + * @return boolean + */ public function execute($image) { $width = $this->argument(0)->type('integer')->required()->value(); diff --git a/src/Intervention/Image/Imagick/Driver.php b/src/Intervention/Image/Imagick/Driver.php index 4f111a1a..32518f25 100644 --- a/src/Intervention/Image/Imagick/Driver.php +++ b/src/Intervention/Image/Imagick/Driver.php @@ -6,15 +6,26 @@ use \Intervention\Image\Size; class Driver extends \Intervention\Image\AbstractDriver { - public $source; - public $encoder; - + /** + * Creates new instance of driver + * + * @param Intervention\Image\Imagick\Source $source + * @param Intervention\Image\Imagick\Encoder $encoder + */ public function __construct(Source $source = null, Encoder $encoder = null) { $this->source = $source ? $source : new Source; $this->encoder = $encoder ? $encoder : new Encoder; } + /** + * Creates new image instance + * + * @param integer $width + * @param integer $height + * @param string $background + * @return Intervention\Image\Image + */ public function newImage($width, $height, $background = null) { $background = new Color($background); @@ -35,6 +46,12 @@ class Driver extends \Intervention\Image\AbstractDriver return $image; } + /** + * Reads given string into color object + * + * @param string $value + * @return AbstractColor + */ public function parseColor($value) { return new Color($value); diff --git a/src/Intervention/Image/Imagick/Encoder.php b/src/Intervention/Image/Imagick/Encoder.php index 38c0bc7e..0166c31e 100644 --- a/src/Intervention/Image/Imagick/Encoder.php +++ b/src/Intervention/Image/Imagick/Encoder.php @@ -4,6 +4,11 @@ namespace Intervention\Image\Imagick; class Encoder extends \Intervention\Image\AbstractEncoder { + /** + * Processes and returns encoded image as JPEG string + * + * @return string + */ protected function processJpeg() { $format = 'jpeg'; @@ -20,6 +25,11 @@ class Encoder extends \Intervention\Image\AbstractEncoder return (string) $imagick; } + /** + * Processes and returns encoded image as PNG string + * + * @return string + */ protected function processPng() { $format = 'png'; @@ -34,6 +44,11 @@ class Encoder extends \Intervention\Image\AbstractEncoder return (string) $imagick; } + /** + * Processes and returns encoded image as GIF string + * + * @return string + */ protected function processGif() { $format = 'gif'; diff --git a/src/Intervention/Image/Imagick/Font.php b/src/Intervention/Image/Imagick/Font.php index 9e89101c..1bda1d37 100644 --- a/src/Intervention/Image/Imagick/Font.php +++ b/src/Intervention/Image/Imagick/Font.php @@ -57,6 +57,7 @@ class Font extends \Intervention\Image\AbstractFont /** * Draws font to given image at given position + * * @param Image $image * @param integer $posx * @param integer $posy diff --git a/src/Intervention/Image/Imagick/Shapes/CircleShape.php b/src/Intervention/Image/Imagick/Shapes/CircleShape.php index 5abe7358..765754de 100644 --- a/src/Intervention/Image/Imagick/Shapes/CircleShape.php +++ b/src/Intervention/Image/Imagick/Shapes/CircleShape.php @@ -6,8 +6,18 @@ use \Intervention\Image\Image; class CircleShape extends EllipseShape { + /** + * Radius of circle in pixels + * + * @var integer + */ public $radius = 100; + /** + * Create new instance of circle + * + * @param integer $radius + */ function __construct($radius = null) { $this->width = is_numeric($radius) ? intval($radius) : $this->radius; @@ -15,6 +25,14 @@ class CircleShape extends EllipseShape $this->radius = is_numeric($radius) ? intval($radius) : $this->radius; } + /** + * Draw current circle on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { return parent::applyToImage($image, $x, $y); diff --git a/src/Intervention/Image/Imagick/Shapes/EllipseShape.php b/src/Intervention/Image/Imagick/Shapes/EllipseShape.php index d6ad06fd..bd3d17dc 100644 --- a/src/Intervention/Image/Imagick/Shapes/EllipseShape.php +++ b/src/Intervention/Image/Imagick/Shapes/EllipseShape.php @@ -7,15 +7,40 @@ use \Intervention\Image\Imagick\Color; class EllipseShape extends \Intervention\Image\AbstractShape { + /** + * Width of ellipse in pixels + * + * @var integer + */ public $width = 100; + + /** + * Height of ellipse in pixels + * + * @var integer + */ public $height = 100; + /** + * Create new ellipse instance + * + * @param integer $width + * @param integer $height + */ function __construct($width = null, $height = null) { $this->width = is_numeric($width) ? intval($width) : $this->width; $this->height = is_numeric($height) ? intval($height) : $this->height; } + /** + * Draw ellipse instance on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $circle = new \ImagickDraw; diff --git a/src/Intervention/Image/Imagick/Shapes/LineShape.php b/src/Intervention/Image/Imagick/Shapes/LineShape.php index 54931649..3fc5b34e 100644 --- a/src/Intervention/Image/Imagick/Shapes/LineShape.php +++ b/src/Intervention/Image/Imagick/Shapes/LineShape.php @@ -7,27 +7,76 @@ use \Intervention\Image\Imagick\Color; class LineShape extends \Intervention\Image\AbstractShape { + /** + * Starting point x-coordinate of line + * + * @var integer + */ public $x = 0; + + /** + * Starting point y-coordinate of line + * + * @var integer + */ public $y = 0; + + /** + * Color of line + * + * @var string + */ public $color = '#000000'; + + /** + * Width of line in pixels + * + * @var integer + */ public $width = 1; + /** + * Create new line shape instance + * + * @param integer $x + * @param integer $y + */ function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : $this->x; $this->y = is_numeric($y) ? intval($y) : $this->y; } + /** + * Set current line color + * + * @param string $color + * @return void + */ public function color($color) { $this->color = $color; } + /** + * Set current line width in pixels + * + * @param integer $width + * @return void + */ public function width($width) { $this->width = $width; } + /** + * Draw current instance of line to given endpoint on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $line = new \ImagickDraw; diff --git a/src/Intervention/Image/Imagick/Shapes/RectangleShape.php b/src/Intervention/Image/Imagick/Shapes/RectangleShape.php index da851001..9e9beb62 100644 --- a/src/Intervention/Image/Imagick/Shapes/RectangleShape.php +++ b/src/Intervention/Image/Imagick/Shapes/RectangleShape.php @@ -7,11 +7,42 @@ use \Intervention\Image\Imagick\Color; class RectangleShape extends \Intervention\Image\AbstractShape { + /** + * X-Coordinate of top-left point + * + * @var integer + */ public $x1 = 0; + + /** + * Y-Coordinate of top-left point + * + * @var integer + */ public $y1 = 0; + + /** + * X-Coordinate of bottom-right point + * + * @var integer + */ public $x2 = 0; + + /** + * Y-Coordinate of bottom-right point + * + * @var integer + */ public $y2 = 0; + /** + * Create new rectangle shape instance + * + * @param integer $x1 + * @param integer $y1 + * @param integer $x2 + * @param integer $y2 + */ function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) { $this->x1 = is_numeric($x1) ? intval($x1) : $this->x1; @@ -20,6 +51,14 @@ class RectangleShape extends \Intervention\Image\AbstractShape $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2; } + /** + * Draw rectangle to given image at certain position + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ public function applyToImage(Image $image, $x = 0, $y = 0) { $rectangle = new \ImagickDraw; diff --git a/src/Intervention/Image/Imagick/Source.php b/src/Intervention/Image/Imagick/Source.php index d9b51fe2..d82c1ddd 100644 --- a/src/Intervention/Image/Imagick/Source.php +++ b/src/Intervention/Image/Imagick/Source.php @@ -7,6 +7,12 @@ use \Intervention\Image\Size; class Source extends \Intervention\Image\AbstractSource { + /** + * Initiates new image from path in filesystem + * + * @param string $path + * @return Intervention\Image\Image + */ public function initFromPath($path) { $core = new \Imagick; @@ -29,6 +35,12 @@ class Source extends \Intervention\Image\AbstractSource return $image; } + /** + * Initiates new image from GD resource + * + * @param Resource $resource + * @return Intervention\Image\Image + */ public function initFromGdResource($resource) { throw new \Intervention\Image\Exception\NotSupportedException( @@ -36,11 +48,23 @@ class Source extends \Intervention\Image\AbstractSource ); } - public function initFromImagick($object) + /** + * Initiates new image from Imagick object + * + * @param Imagick $object + * @return Intervention\Image\Image + */ + public function initFromImagick(\Imagick $object) { return new Image(new Driver, $object); } + /** + * Initiates new image from binary data + * + * @param string $data + * @return Intervention\Image\Image + */ public function initFromBinary($binary) { $core = new \Imagick; diff --git a/src/Intervention/Image/Point.php b/src/Intervention/Image/Point.php index 5a3530c4..55837d82 100644 --- a/src/Intervention/Image/Point.php +++ b/src/Intervention/Image/Point.php @@ -4,25 +4,58 @@ namespace Intervention\Image; class Point { + /** + * X coordinate + * + * @var integer + */ public $x; + + /** + * Y coordinate + * + * @var integer + */ public $y; + /** + * Creates a new instance + * + * @param integer $x + * @param integer $y + */ public function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : 0; $this->y = is_numeric($y) ? intval($y) : 0; } + /** + * Sets X coordinate + * + * @param integer $x + */ public function setX($x) { $this->x = intval($x); } + /** + * Sets Y coordinate + * + * @param integer $y + */ public function setY($y) { $this->y = intval($y); } + /** + * Sets both X and Y coordinate + * + * @param integer $x + * @param integer $y + */ public function setPosition($x, $y) { $this->setX($x); diff --git a/src/Intervention/Image/Response.php b/src/Intervention/Image/Response.php index 67ddca47..2eb7fa26 100644 --- a/src/Intervention/Image/Response.php +++ b/src/Intervention/Image/Response.php @@ -4,10 +4,34 @@ namespace Intervention\Image; class Response { + /** + * Image that should be displayed by response + * + * @var Intervention\Image\Image + */ public $image; + + /** + * Format of displayed image + * + * @var string + */ public $format; + + /** + * Quality of displayed image + * + * @var integer + */ public $quality; + /** + * Creates a new instance of response + * + * @param Image $image + * @param string $format + * @param integer $quality + */ public function __construct(Image $image, $format = null, $quality = null) { $this->image = $image; @@ -15,6 +39,11 @@ class Response $this->quality = $quality ? $quality : 90; } + /** + * Builds response according to settings + * + * @return mixed + */ public function make() { $this->image->encode($this->format, $this->quality); diff --git a/src/Intervention/Image/Size.php b/src/Intervention/Image/Size.php index 807cc770..9103dab4 100644 --- a/src/Intervention/Image/Size.php +++ b/src/Intervention/Image/Size.php @@ -6,10 +6,34 @@ use \Closure; class Size { + /** + * Width + * + * @var integer + */ public $width; + + /** + * Height + * + * @var integer + */ public $height; + + /** + * Pivot point + * + * @var Intervention\Image\Point + */ public $pivot; + /** + * Creates a new Size instance + * + * @param integer $width + * @param integer $height + * @param Point $pivot + */ public function __construct($width = null, $height = null, Point $pivot = null) { $this->width = is_numeric($width) ? intval($width) : 1; @@ -17,32 +41,66 @@ class Size $this->pivot = $pivot ? $pivot : new Point; } + /** + * Set the width and height absolutely + * + * @param integer $width + * @param integer $height + */ public function set($width, $height) { $this->width = $width; $this->height = $height; } + /** + * Set current pivot point + * + * @param Point $point + */ public function setPivot(Point $point) { $this->pivot = $point; } + /** + * Get the current width + * + * @return integer + */ public function getWidth() { return $this->width; } + /** + * Get the current height + * + * @return integer + */ public function getHeight() { return $this->height; } + /** + * Calculate the current aspect ratio + * + * @return float + */ public function getRatio() { return $this->width / $this->height; } + /** + * Resize to desired width and/or height + * + * @param integer $width + * @param integer $height + * @param Closure $callback + * @return Size + */ public function resize($width, $height, Closure $callback = null) { if (is_null($width) && is_null($height)) { @@ -99,6 +157,13 @@ class Size return $this; } + /** + * Calculate the relative position to another Size + * based on the pivot point settings of both sizes. + * + * @param Size $size + * @return Intervention\Image\Point + */ public function relativePosition(Size $size) { $x = $this->pivot->x - $size->pivot->x; @@ -107,6 +172,12 @@ class Size return new Point($x, $y); } + /** + * Resize given Size to best fitting size of current size. + * + * @param Size $size + * @return Intervention\Image\Size + */ public function fit(Size $size) { // create size with auto height @@ -140,11 +211,26 @@ class Size return $size; } + /** + * Checks if given size fits into current size + * + * @param Size $size + * @return boolean + */ public function fitsInto(Size $size) { return ($this->width <= $size->width) && ($this->height <= $size->height); } + /** + * Aligns current size's pivot point to given position + * and moves point automatically by offset. + * + * @param string $position + * @param integer $offset_x + * @param integer $offset_y + * @return Intervention\Image\Size + */ public function align($position, $offset_x = 0, $offset_y = 0) { switch (strtolower($position)) { @@ -224,6 +310,12 @@ class Size return $this; } + /** + * Runs constraints on current size + * + * @param Closure $callback + * @return Intervention\Image\Constraint + */ private function getConstraint(Closure $callback = null) { $constraint = new Constraint(clone $this); diff --git a/src/config/config.php b/src/config/config.php index 166f655b..b106809e 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -2,7 +2,19 @@ return array( - // imagick, gd + /* + |-------------------------------------------------------------------------- + | Image Driver + |-------------------------------------------------------------------------- + | + | Intervention Image supports "GD Library" and "Imagick" to process images + | internally. You may choose one of them according to your PHP + | configuration. By default PHP's "GD Library" implementation is used. + | + | Supported: "gd", "imagick" + | + */ + 'driver' => 'gd' );