From 4e252a3ffa2c94d9d4d2fb7146220b1e87d9ee04 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 18 May 2014 18:07:03 +0200 Subject: [PATCH] fixed coding standards --- src/Intervention/Image/AbstractColor.php | 6 +- src/Intervention/Image/AbstractDriver.php | 2 +- src/Intervention/Image/AbstractEncoder.php | 4 +- src/Intervention/Image/AbstractFont.php | 2 +- src/Intervention/Image/Commands/Argument.php | 2 +- .../Image/Commands/CircleCommand.php | 2 +- .../Image/Commands/EllipseCommand.php | 2 +- .../Image/Commands/LineCommand.php | 2 +- .../Image/Commands/RectangleCommand.php | 2 +- .../Image/Commands/TextCommand.php | 2 +- src/Intervention/Image/Constraint.php | 2 +- .../Image/Gd/Commands/FillCommand.php | 2 +- .../Image/Gd/Commands/GetSizeCommand.php | 2 +- .../Image/Gd/Commands/HeightenCommand.php | 2 +- .../Image/Gd/Commands/InterlaceCommand.php | 2 +- .../Image/Gd/Commands/LimitColorsCommand.php | 2 +- .../Image/Gd/Commands/MaskCommand.php | 6 +- .../Image/Gd/Commands/PickColorCommand.php | 2 +- .../Image/Gd/Commands/ResetCommand.php | 2 +- .../Image/Gd/Commands/ResizeCanvasCommand.php | 8 +- .../Image/Gd/Commands/TrimCommand.php | 12 +-- .../Image/Gd/Commands/WidenCommand.php | 2 +- src/Intervention/Image/Gd/Driver.php | 8 +- src/Intervention/Image/Gd/Encoder.php | 2 +- .../Image/Gd/Shapes/CircleShape.php | 4 +- .../Image/Gd/Shapes/EllipseShape.php | 2 +- .../Image/Gd/Shapes/LineShape.php | 2 +- .../Image/Gd/Shapes/RectangleShape.php | 2 +- src/Intervention/Image/ImageManager.php | 2 +- .../Image/ImageServiceProvider.php | 78 +++++++++---------- src/Intervention/Image/Imagick/Color.php | 10 +-- .../Image/Imagick/Commands/FillCommand.php | 10 +-- .../Image/Imagick/Commands/FitCommand.php | 10 +-- .../Image/Imagick/Commands/GetSizeCommand.php | 2 +- .../Imagick/Commands/HeightenCommand.php | 2 +- .../Imagick/Commands/LimitColorsCommand.php | 10 +-- .../Image/Imagick/Commands/MaskCommand.php | 8 +- .../Image/Imagick/Commands/ResetCommand.php | 2 +- .../Imagick/Commands/ResizeCanvasCommand.php | 10 +-- .../Image/Imagick/Commands/WidenCommand.php | 2 +- src/Intervention/Image/Imagick/Driver.php | 8 +- src/Intervention/Image/Imagick/Encoder.php | 2 +- src/Intervention/Image/Imagick/Font.php | 6 +- .../Image/Imagick/Shapes/CircleShape.php | 4 +- .../Image/Imagick/Shapes/EllipseShape.php | 8 +- .../Image/Imagick/Shapes/LineShape.php | 2 +- .../Image/Imagick/Shapes/RectangleShape.php | 8 +- src/Intervention/Image/Imagick/Source.php | 2 +- src/Intervention/Image/Point.php | 2 +- src/Intervention/Image/Response.php | 6 +- src/Intervention/Image/Size.php | 12 +-- 51 files changed, 148 insertions(+), 148 deletions(-) diff --git a/src/Intervention/Image/AbstractColor.php b/src/Intervention/Image/AbstractColor.php index 50341e9e..8688be8c 100644 --- a/src/Intervention/Image/AbstractColor.php +++ b/src/Intervention/Image/AbstractColor.php @@ -134,7 +134,7 @@ abstract class AbstractColor case is_null($value): $this->initFromArray(array(0, 0, 0, 0)); break; - + default: throw new \Intervention\Image\Exception\NotReadableException( "Color format ({$value}) cannot be read." @@ -154,7 +154,7 @@ abstract class AbstractColor public function format($type) { switch (strtolower($type)) { - + case 'rgba': return $this->getRgba(); break; @@ -167,7 +167,7 @@ abstract class AbstractColor case 'integer': return $this->getInt(); break; - + case 'array': return $this->getArray(); break; diff --git a/src/Intervention/Image/AbstractDriver.php b/src/Intervention/Image/AbstractDriver.php index ac30e479..dce552e2 100644 --- a/src/Intervention/Image/AbstractDriver.php +++ b/src/Intervention/Image/AbstractDriver.php @@ -42,7 +42,7 @@ abstract class AbstractDriver * @return boolean */ abstract protected function coreAvailable(); - + /** * Initiates new image from given input * diff --git a/src/Intervention/Image/AbstractEncoder.php b/src/Intervention/Image/AbstractEncoder.php index 0b4e0638..894e3012 100644 --- a/src/Intervention/Image/AbstractEncoder.php +++ b/src/Intervention/Image/AbstractEncoder.php @@ -86,8 +86,8 @@ abstract class AbstractEncoder */ protected function processDataUrl() { - return sprintf('data:%s;base64,%s', - $this->image->mime, + return sprintf('data:%s;base64,%s', + $this->image->mime, base64_encode($this->process($this->image, null, $this->quality)) ); } diff --git a/src/Intervention/Image/AbstractFont.php b/src/Intervention/Image/AbstractFont.php index 0a5c0db6..5510b353 100644 --- a/src/Intervention/Image/AbstractFont.php +++ b/src/Intervention/Image/AbstractFont.php @@ -183,5 +183,5 @@ abstract class AbstractFont } return false; - } + } } diff --git a/src/Intervention/Image/Commands/Argument.php b/src/Intervention/Image/Commands/Argument.php index 518d0c7a..c48b973c 100644 --- a/src/Intervention/Image/Commands/Argument.php +++ b/src/Intervention/Image/Commands/Argument.php @@ -88,7 +88,7 @@ class Argument } switch (strtolower($type)) { - + case 'bool': case 'boolean': $fail = ! is_bool($value); diff --git a/src/Intervention/Image/Commands/CircleCommand.php b/src/Intervention/Image/Commands/CircleCommand.php index b047e4a5..7ccd1cdf 100644 --- a/src/Intervention/Image/Commands/CircleCommand.php +++ b/src/Intervention/Image/Commands/CircleCommand.php @@ -19,7 +19,7 @@ class CircleCommand extends \Intervention\Image\Commands\AbstractCommand $y = $this->argument(2)->type('numeric')->required()->value(); $callback = $this->argument(3)->type('closure')->value(); - $circle_classname = sprintf('\Intervention\Image\%s\Shapes\CircleShape', + $circle_classname = sprintf('\Intervention\Image\%s\Shapes\CircleShape', $image->getDriver()->getDriverName()); $circle = new $circle_classname($radius); diff --git a/src/Intervention/Image/Commands/EllipseCommand.php b/src/Intervention/Image/Commands/EllipseCommand.php index d482071e..7fb2fd96 100644 --- a/src/Intervention/Image/Commands/EllipseCommand.php +++ b/src/Intervention/Image/Commands/EllipseCommand.php @@ -20,7 +20,7 @@ class EllipseCommand extends \Intervention\Image\Commands\AbstractCommand $y = $this->argument(3)->type('numeric')->required()->value(); $callback = $this->argument(4)->type('closure')->value(); - $ellipse_classname = sprintf('\Intervention\Image\%s\Shapes\EllipseShape', + $ellipse_classname = sprintf('\Intervention\Image\%s\Shapes\EllipseShape', $image->getDriver()->getDriverName()); $ellipse = new $ellipse_classname($width, $height); diff --git a/src/Intervention/Image/Commands/LineCommand.php b/src/Intervention/Image/Commands/LineCommand.php index c3e2e337..8f48f385 100644 --- a/src/Intervention/Image/Commands/LineCommand.php +++ b/src/Intervention/Image/Commands/LineCommand.php @@ -20,7 +20,7 @@ class LineCommand extends \Intervention\Image\Commands\AbstractCommand $y2 = $this->argument(3)->type('numeric')->required()->value(); $callback = $this->argument(4)->type('closure')->value(); - $line_classname = sprintf('\Intervention\Image\%s\Shapes\LineShape', + $line_classname = sprintf('\Intervention\Image\%s\Shapes\LineShape', $image->getDriver()->getDriverName()); $line = new $line_classname($x2, $y2); diff --git a/src/Intervention/Image/Commands/RectangleCommand.php b/src/Intervention/Image/Commands/RectangleCommand.php index 9016162d..cb05d7a3 100644 --- a/src/Intervention/Image/Commands/RectangleCommand.php +++ b/src/Intervention/Image/Commands/RectangleCommand.php @@ -20,7 +20,7 @@ class RectangleCommand extends \Intervention\Image\Commands\AbstractCommand $y2 = $this->argument(3)->type('numeric')->required()->value(); $callback = $this->argument(4)->type('closure')->value(); - $rectangle_classname = sprintf('\Intervention\Image\%s\Shapes\RectangleShape', + $rectangle_classname = sprintf('\Intervention\Image\%s\Shapes\RectangleShape', $image->getDriver()->getDriverName()); $rectangle = new $rectangle_classname($x1, $y1, $x2, $y2); diff --git a/src/Intervention/Image/Commands/TextCommand.php b/src/Intervention/Image/Commands/TextCommand.php index 09d8267c..81278528 100644 --- a/src/Intervention/Image/Commands/TextCommand.php +++ b/src/Intervention/Image/Commands/TextCommand.php @@ -18,7 +18,7 @@ class TextCommand extends \Intervention\Image\Commands\AbstractCommand $y = $this->argument(2)->type('numeric')->value(0); $callback = $this->argument(3)->type('closure')->value(); - $fontclassname = sprintf('\Intervention\Image\%s\Font', + $fontclassname = sprintf('\Intervention\Image\%s\Font', $image->getDriver()->getDriverName()); $font = new $fontclassname($text); diff --git a/src/Intervention/Image/Constraint.php b/src/Intervention/Image/Constraint.php index 43c45b09..cfb36501 100644 --- a/src/Intervention/Image/Constraint.php +++ b/src/Intervention/Image/Constraint.php @@ -33,7 +33,7 @@ class Constraint * * @param Size $size */ - public function __construct(Size $size) + public function __construct(Size $size) { $this->size = $size; } diff --git a/src/Intervention/Image/Gd/Commands/FillCommand.php b/src/Intervention/Image/Gd/Commands/FillCommand.php index 35df75ff..e6cee133 100644 --- a/src/Intervention/Image/Gd/Commands/FillCommand.php +++ b/src/Intervention/Image/Gd/Commands/FillCommand.php @@ -41,7 +41,7 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand imagealphablending($resource, true); if (is_int($x) && is_int($y)) { - + // resource should be visible through transparency $base = $image->getDriver()->newImage($width, $height)->getCore(); imagecopy($base, $resource, 0, 0, 0, 0, $width, $height); diff --git a/src/Intervention/Image/Gd/Commands/GetSizeCommand.php b/src/Intervention/Image/Gd/Commands/GetSizeCommand.php index 095eb5d1..6c19c5c2 100644 --- a/src/Intervention/Image/Gd/Commands/GetSizeCommand.php +++ b/src/Intervention/Image/Gd/Commands/GetSizeCommand.php @@ -15,7 +15,7 @@ class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand public function execute($image) { $this->setOutput(new Size( - imagesx($image->getCore()), + imagesx($image->getCore()), imagesy($image->getCore()) )); diff --git a/src/Intervention/Image/Gd/Commands/HeightenCommand.php b/src/Intervention/Image/Gd/Commands/HeightenCommand.php index 132664d5..6df46564 100644 --- a/src/Intervention/Image/Gd/Commands/HeightenCommand.php +++ b/src/Intervention/Image/Gd/Commands/HeightenCommand.php @@ -19,7 +19,7 @@ class HeightenCommand extends ResizeCommand $this->arguments[2] = function ($constraint) { $constraint->aspectRatio(); }; - + return parent::execute($image); } } diff --git a/src/Intervention/Image/Gd/Commands/InterlaceCommand.php b/src/Intervention/Image/Gd/Commands/InterlaceCommand.php index efffde5e..523445b4 100644 --- a/src/Intervention/Image/Gd/Commands/InterlaceCommand.php +++ b/src/Intervention/Image/Gd/Commands/InterlaceCommand.php @@ -13,7 +13,7 @@ class InterlaceCommand extends \Intervention\Image\Commands\AbstractCommand public function execute($image) { $mode = $this->argument(0)->type('bool')->value(true); - + imageinterlace($image->getCore(), $mode); return true; diff --git a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php index 91b37b70..e33bb194 100644 --- a/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php +++ b/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php @@ -38,7 +38,7 @@ class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand // copy original image imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height); - + if ($count <= 256) { // decrease colors imagetruecolortopalette($resource, true, $count); diff --git a/src/Intervention/Image/Gd/Commands/MaskCommand.php b/src/Intervention/Image/Gd/Commands/MaskCommand.php index 2f314ea6..2e06a054 100644 --- a/src/Intervention/Image/Gd/Commands/MaskCommand.php +++ b/src/Intervention/Image/Gd/Commands/MaskCommand.php @@ -50,11 +50,11 @@ class MaskCommand extends \Intervention\Image\Commands\AbstractCommand if ($alpha[3] == 0) { // transparent as black $alpha = 0; } else { - + // $alpha = floatval(round((($alpha[0] + $alpha[1] + $alpha[3]) / 3) / 255, 2)); - + // image is greyscale, so channel doesn't matter (use red channel) - $alpha = floatval(round($alpha[0] / 255, 2)); + $alpha = floatval(round($alpha[0] / 255, 2)); } } diff --git a/src/Intervention/Image/Gd/Commands/PickColorCommand.php b/src/Intervention/Image/Gd/Commands/PickColorCommand.php index b5233d80..b09807b7 100644 --- a/src/Intervention/Image/Gd/Commands/PickColorCommand.php +++ b/src/Intervention/Image/Gd/Commands/PickColorCommand.php @@ -22,7 +22,7 @@ class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand $color = imagecolorat($image->getCore(), $x, $y); if ( ! imageistruecolor($image->getCore())) { - $color = imagecolorsforindex($image->getCore(), $color); + $color = imagecolorsforindex($image->getCore(), $color); $color['alpha'] = round(1 - $color['alpha'] / 127, 2); } diff --git a/src/Intervention/Image/Gd/Commands/ResetCommand.php b/src/Intervention/Image/Gd/Commands/ResetCommand.php index 5da7a5e3..bfd7d18a 100644 --- a/src/Intervention/Image/Gd/Commands/ResetCommand.php +++ b/src/Intervention/Image/Gd/Commands/ResetCommand.php @@ -13,7 +13,7 @@ class ResetCommand extends \Intervention\Image\Commands\AbstractCommand public function execute($image) { if (is_resource($backup = $image->getBackup())) { - + // destroy old resource imagedestroy($image->getCore()); // reset to new resource diff --git a/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php b/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php index bb951c97..7f9c6690 100644 --- a/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php +++ b/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php @@ -27,7 +27,7 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand // check of only width or height is set $width = is_null($width) ? $original_width : intval($width); $height = is_null($height) ? $original_height : intval($height); - + // check on relative width/height if ($relative) { $width = $original_width + $width; @@ -37,8 +37,8 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand // check for negative width/height $width = ($width <= 0) ? $width + $original_width : $width; $height = ($height <= 0) ? $height + $original_height : $height; - - // create new canvas + + // create new canvas $canvas = $image->getDriver()->newImage($width, $height, $bgcolor); // set copy position @@ -60,7 +60,7 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand if ($height <= $original_height) { $dst_y = 0; $src_y = $canvas_pos->y; - $src_h = $canvas_size->height; + $src_h = $canvas_size->height; } else { $dst_y = $image_pos->y; $src_y = 0; diff --git a/src/Intervention/Image/Gd/Commands/TrimCommand.php b/src/Intervention/Image/Gd/Commands/TrimCommand.php index ed9d7c32..e76cb7ae 100644 --- a/src/Intervention/Image/Gd/Commands/TrimCommand.php +++ b/src/Intervention/Image/Gd/Commands/TrimCommand.php @@ -109,7 +109,7 @@ class TrimCommand extends ResizeCommand $checkColor->g = 0; $checkColor->b = 0; } - + if ($color->differs($checkColor, $tolerance)) { $top_x = max(0, $x - $feather); break 2; @@ -125,7 +125,7 @@ class TrimCommand extends ResizeCommand for ($y=($height-1); $y >= floor($height/2)-1; $y--) { for ($x=$top_x; $x < $width; $x++) { - + $checkColor = $image->pickColor($x, $y, 'object'); if ($checkTransparency) { @@ -133,7 +133,7 @@ class TrimCommand extends ResizeCommand $checkColor->g = 0; $checkColor->b = 0; } - + if ($color->differs($checkColor, $tolerance)) { $bottom_y = min($height, $y+1 + $feather); break 2; @@ -149,9 +149,9 @@ class TrimCommand extends ResizeCommand for ($x=($width-1); $x >= floor($width/2)-1; $x--) { for ($y=$top_y; $y < $bottom_y; $y++) { - + $checkColor = $image->pickColor($x, $y, 'object'); - + if ($checkTransparency) { $checkColor->r = 0; $checkColor->g = 0; @@ -167,7 +167,7 @@ class TrimCommand extends ResizeCommand } } - + // trim parts of image return $this->modify($image, 0, 0, $top_x, $top_y, ($bottom_x-$top_x), ($bottom_y-$top_y), ($bottom_x-$top_x), ($bottom_y-$top_y)); diff --git a/src/Intervention/Image/Gd/Commands/WidenCommand.php b/src/Intervention/Image/Gd/Commands/WidenCommand.php index 815bdfd3..edb4350c 100644 --- a/src/Intervention/Image/Gd/Commands/WidenCommand.php +++ b/src/Intervention/Image/Gd/Commands/WidenCommand.php @@ -19,7 +19,7 @@ class WidenCommand extends ResizeCommand $this->arguments[2] = function ($constraint) { $constraint->aspectRatio(); }; - + return parent::execute($image); } } diff --git a/src/Intervention/Image/Gd/Driver.php b/src/Intervention/Image/Gd/Driver.php index 466ecb31..d2c33581 100644 --- a/src/Intervention/Image/Gd/Driver.php +++ b/src/Intervention/Image/Gd/Driver.php @@ -12,8 +12,8 @@ class Driver extends \Intervention\Image\AbstractDriver * @param Intervention\Image\Gd\Source $source * @param Intervention\Image\Gd\Encoder $encoder */ - public function __construct(Source $source = null, Encoder $encoder = null) - { + public function __construct(Source $source = null, Encoder $encoder = null) + { if ( ! $this->coreAvailable()) { throw new \Intervention\Image\Exception\NotSupportedException( "GD Library extension not available with this PHP installation." @@ -21,8 +21,8 @@ class Driver extends \Intervention\Image\AbstractDriver } $this->source = $source ? $source : new Source; - $this->encoder = $encoder ? $encoder : new Encoder; - } + $this->encoder = $encoder ? $encoder : new Encoder; + } /** * Creates new image instance diff --git a/src/Intervention/Image/Gd/Encoder.php b/src/Intervention/Image/Gd/Encoder.php index c1efb03c..9f1582ee 100644 --- a/src/Intervention/Image/Gd/Encoder.php +++ b/src/Intervention/Image/Gd/Encoder.php @@ -16,7 +16,7 @@ class Encoder extends \Intervention\Image\AbstractEncoder $this->image->mime = image_type_to_mime_type(IMAGETYPE_JPEG); $buffer = ob_get_contents(); ob_end_clean(); - + return $buffer; } diff --git a/src/Intervention/Image/Gd/Shapes/CircleShape.php b/src/Intervention/Image/Gd/Shapes/CircleShape.php index 1383ad26..15b606e2 100644 --- a/src/Intervention/Image/Gd/Shapes/CircleShape.php +++ b/src/Intervention/Image/Gd/Shapes/CircleShape.php @@ -18,12 +18,12 @@ class CircleShape extends EllipseShape * * @param integer $radius */ - function __construct($radius = null) + public function __construct($radius = null) { $this->width = is_numeric($radius) ? intval($radius) : $this->radius; $this->height = is_numeric($radius) ? intval($radius) : $this->radius; $this->radius = is_numeric($radius) ? intval($radius) : $this->radius; - } + } /** * Draw current circle on given image diff --git a/src/Intervention/Image/Gd/Shapes/EllipseShape.php b/src/Intervention/Image/Gd/Shapes/EllipseShape.php index 35b29134..23e3dfef 100644 --- a/src/Intervention/Image/Gd/Shapes/EllipseShape.php +++ b/src/Intervention/Image/Gd/Shapes/EllipseShape.php @@ -27,7 +27,7 @@ class EllipseShape extends \Intervention\Image\AbstractShape * @param integer $width * @param integer $height */ - function __construct($width = null, $height = null) + public function __construct($width = null, $height = null) { $this->width = is_numeric($width) ? intval($width) : $this->width; $this->height = is_numeric($height) ? intval($height) : $this->height; diff --git a/src/Intervention/Image/Gd/Shapes/LineShape.php b/src/Intervention/Image/Gd/Shapes/LineShape.php index 3e32055c..c3c1ea36 100644 --- a/src/Intervention/Image/Gd/Shapes/LineShape.php +++ b/src/Intervention/Image/Gd/Shapes/LineShape.php @@ -41,7 +41,7 @@ class LineShape extends \Intervention\Image\AbstractShape * @param integer $x * @param integer $y */ - function __construct($x = null, $y = null) + public function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : $this->x; $this->y = is_numeric($y) ? intval($y) : $this->y; diff --git a/src/Intervention/Image/Gd/Shapes/RectangleShape.php b/src/Intervention/Image/Gd/Shapes/RectangleShape.php index ad780113..c25ebe5e 100644 --- a/src/Intervention/Image/Gd/Shapes/RectangleShape.php +++ b/src/Intervention/Image/Gd/Shapes/RectangleShape.php @@ -43,7 +43,7 @@ class RectangleShape extends \Intervention\Image\AbstractShape * @param integer $x2 * @param integer $y2 */ - function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) + public function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) { $this->x1 = is_numeric($x1) ? intval($x1) : $this->x1; $this->y1 = is_numeric($y1) ? intval($y1) : $this->y1; diff --git a/src/Intervention/Image/ImageManager.php b/src/Intervention/Image/ImageManager.php index a452b99d..12d21618 100644 --- a/src/Intervention/Image/ImageManager.php +++ b/src/Intervention/Image/ImageManager.php @@ -100,7 +100,7 @@ class ImageManager $imagecache = new ImageCache($this); $imagecache = is_callable($callback) ? $callback($imagecache) : $imagecache; - return $imagecache->get($lifetime, $returnObj); + return $imagecache->get($lifetime, $returnObj); } throw new \Intervention\Image\Exception\NotSupportedException( diff --git a/src/Intervention/Image/ImageServiceProvider.php b/src/Intervention/Image/ImageServiceProvider.php index 7f0fae12..1c5c7797 100644 --- a/src/Intervention/Image/ImageServiceProvider.php +++ b/src/Intervention/Image/ImageServiceProvider.php @@ -3,39 +3,39 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Http\Response; -class ImageServiceProvider extends ServiceProvider { +class ImageServiceProvider extends ServiceProvider +{ + /** + * Indicates if loading of the provider is deferred. + * + * @var bool + */ + protected $defer = false; - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + $this->package('intervention/image'); + } - /** - * Bootstrap the application events. - * - * @return void - */ - public function boot() - { - $this->package('intervention/image'); - } + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $app = $this->app; - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $app = $this->app; + $app['image'] = $app->share(function ($app) { + return new ImageManager($app['config']); + }); - $app['image'] = $app->share(function ($app) { - return new ImageManager($app['config']); - }); - - // try to create imagecache route only if imagecache is present + // try to create imagecache route only if imagecache is present if (class_exists('Intervention\Image\ImageCache')) { // load imagecache config @@ -95,16 +95,16 @@ class ImageServiceProvider extends ServiceProvider { }))->where(array('template' => join('|', array_keys($config->get('imagecache::templates'))), 'filename' => '^[\/\w.-]+$')); } } - } + } - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('image'); - } + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('image'); + } } diff --git a/src/Intervention/Image/Imagick/Color.php b/src/Intervention/Image/Imagick/Color.php index c558a038..498b0936 100644 --- a/src/Intervention/Image/Imagick/Color.php +++ b/src/Intervention/Image/Imagick/Color.php @@ -49,7 +49,7 @@ class Color extends \Intervention\Image\AbstractColor list($r, $g, $b) = $array; $a = 1; } - + $this->setPixel($r, $g, $b, $a); } @@ -129,9 +129,9 @@ class Color extends \Intervention\Image\AbstractColor */ public function getHex($prefix = '') { - return sprintf('%s%02x%02x%02x', $prefix, - $this->getRedValue(), - $this->getGreenValue(), + return sprintf('%s%02x%02x%02x', $prefix, + $this->getRedValue(), + $this->getGreenValue(), $this->getBlueValue() ); } @@ -158,7 +158,7 @@ class Color extends \Intervention\Image\AbstractColor */ public function getRgba() { - return sprintf('rgba(%d, %d, %d, %.2f)', + return sprintf('rgba(%d, %d, %d, %.2f)', $this->getRedValue(), $this->getGreenValue(), $this->getBlueValue(), diff --git a/src/Intervention/Image/Imagick/Commands/FillCommand.php b/src/Intervention/Image/Imagick/Commands/FillCommand.php index 5ed4caf6..f95259c7 100644 --- a/src/Intervention/Image/Imagick/Commands/FillCommand.php +++ b/src/Intervention/Image/Imagick/Commands/FillCommand.php @@ -21,7 +21,7 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand $y = $this->argument(2)->type('integer')->value(); $imagick = $image->getCore(); - + try { // set image filling $source = new Source; @@ -39,7 +39,7 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand // flood fill with texture if ($filling instanceof Image) { - // create tile + // create tile $tile = clone $image->getCore(); // mask away color at position @@ -50,7 +50,7 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand // fill canvas with texture $canvas = $canvas->textureImage($filling->getCore()); - + // merge canvas and tile $canvas->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0); @@ -74,8 +74,8 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand $alpha = clone $image->getCore(); // merge original with canvas and tile - $image->getCore()->compositeImage($canvas, \Imagick::COMPOSITE_DEFAULT, 0, 0); - $image->getCore()->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0); + $image->getCore()->compositeImage($canvas, \Imagick::COMPOSITE_DEFAULT, 0, 0); + $image->getCore()->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0); // restore alpha channel of original image $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); diff --git a/src/Intervention/Image/Imagick/Commands/FitCommand.php b/src/Intervention/Image/Imagick/Commands/FitCommand.php index 5dd01d91..8947b71f 100644 --- a/src/Intervention/Image/Imagick/Commands/FitCommand.php +++ b/src/Intervention/Image/Imagick/Commands/FitCommand.php @@ -22,16 +22,16 @@ class FitCommand extends \Intervention\Image\Commands\AbstractCommand // crop image $image->getCore()->cropImage( - $fitted->width, - $fitted->height, - $fitted->pivot->x, + $fitted->width, + $fitted->height, + $fitted->pivot->x, $fitted->pivot->y ); - + // resize image $image->getCore()->resizeImage($width, $height, \Imagick::FILTER_BOX, 1); $image->getCore()->setImagePage(0,0,0,0); - + return true; } } diff --git a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php index d89b2c68..c46565cc 100644 --- a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php +++ b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php @@ -17,7 +17,7 @@ class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand $info = $image->getCore()->identifyImage(true); $this->setOutput(new Size( - $info['geometry']['width'], + $info['geometry']['width'], $info['geometry']['height'] )); diff --git a/src/Intervention/Image/Imagick/Commands/HeightenCommand.php b/src/Intervention/Image/Imagick/Commands/HeightenCommand.php index adaf8e5e..47a38712 100644 --- a/src/Intervention/Image/Imagick/Commands/HeightenCommand.php +++ b/src/Intervention/Image/Imagick/Commands/HeightenCommand.php @@ -19,7 +19,7 @@ class HeightenCommand extends ResizeCommand $this->arguments[2] = function ($constraint) { $constraint->aspectRatio(); }; - + return parent::execute($image); } } diff --git a/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php b/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php index 85e8967b..1e79877d 100644 --- a/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php +++ b/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php @@ -26,7 +26,7 @@ class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand $alpha->negateImage(false); if ($matte) { - + // get matte color $mattecolor = $image->getDriver()->parseColor($matte)->getPixel(); @@ -40,18 +40,18 @@ class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand // copy new alpha to canvas $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); - + // replace core $image->setCore($canvas); } else { - + $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false); $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); } - + return true; - + } } diff --git a/src/Intervention/Image/Imagick/Commands/MaskCommand.php b/src/Intervention/Image/Imagick/Commands/MaskCommand.php index 7f6986c3..3dbf9784 100644 --- a/src/Intervention/Image/Imagick/Commands/MaskCommand.php +++ b/src/Intervention/Image/Imagick/Commands/MaskCommand.php @@ -27,7 +27,7 @@ class MaskCommand extends \Intervention\Image\Commands\AbstractCommand $mask->resize($image_size->width, $image_size->height); } - $imagick->setImageMatte(true); + $imagick->setImageMatte(true); if ($mask_w_alpha) { @@ -35,7 +35,7 @@ class MaskCommand extends \Intervention\Image\Commands\AbstractCommand $imagick->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DSTIN, 0, 0); } else { - + // get alpha channel of original as greyscale image $original_alpha = clone $imagick; $original_alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA); @@ -48,11 +48,11 @@ class MaskCommand extends \Intervention\Image\Commands\AbstractCommand // combine both alphas from original and mask $original_alpha->compositeImage($mask_alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); - + // mask the image with the alpha combination $imagick->compositeImage($original_alpha, \Imagick::COMPOSITE_DSTIN, 0, 0); } - return true; + return true; } } diff --git a/src/Intervention/Image/Imagick/Commands/ResetCommand.php b/src/Intervention/Image/Imagick/Commands/ResetCommand.php index 5094e943..62235592 100644 --- a/src/Intervention/Image/Imagick/Commands/ResetCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ResetCommand.php @@ -15,7 +15,7 @@ class ResetCommand extends \Intervention\Image\Commands\AbstractCommand $backup = $image->getBackup(); if ($backup instanceof \Imagick) { - + // destroy old core $image->getCore()->clear(); diff --git a/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php b/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php index 21d9269b..c8a04484 100644 --- a/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php +++ b/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php @@ -24,7 +24,7 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand // check of only width or height is set $width = is_null($width) ? $original_width : intval($width); $height = is_null($height) ? $original_height : intval($height); - + // check on relative width/height if ($relative) { $width = $original_width + $width; @@ -34,8 +34,8 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand // check for negative width/height $width = ($width <= 0) ? $width + $original_width : $width; $height = ($height <= 0) ? $height + $original_height : $height; - - // create new canvas + + // create new canvas $canvas = $image->getDriver()->newImage($width, $height, $bgcolor); // set copy position @@ -43,7 +43,7 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand $image_size = $image->getSize()->align($anchor); $canvas_pos = $image_size->relativePosition($canvas_size); $image_pos = $canvas_size->relativePosition($image_size); - + if ($width <= $original_width) { $dst_x = 0; $src_x = $canvas_pos->x; @@ -57,7 +57,7 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand if ($height <= $original_height) { $dst_y = 0; $src_y = $canvas_pos->y; - $src_h = $canvas_size->height; + $src_h = $canvas_size->height; } else { $dst_y = $image_pos->y; $src_y = 0; diff --git a/src/Intervention/Image/Imagick/Commands/WidenCommand.php b/src/Intervention/Image/Imagick/Commands/WidenCommand.php index 954c2205..54551163 100644 --- a/src/Intervention/Image/Imagick/Commands/WidenCommand.php +++ b/src/Intervention/Image/Imagick/Commands/WidenCommand.php @@ -19,7 +19,7 @@ class WidenCommand extends ResizeCommand $this->arguments[2] = function ($constraint) { $constraint->aspectRatio(); }; - + return parent::execute($image); } } diff --git a/src/Intervention/Image/Imagick/Driver.php b/src/Intervention/Image/Imagick/Driver.php index 333cff40..2758b4ee 100644 --- a/src/Intervention/Image/Imagick/Driver.php +++ b/src/Intervention/Image/Imagick/Driver.php @@ -12,8 +12,8 @@ class Driver extends \Intervention\Image\AbstractDriver * @param Intervention\Image\Imagick\Source $source * @param Intervention\Image\Imagick\Encoder $encoder */ - public function __construct(Source $source = null, Encoder $encoder = null) - { + public function __construct(Source $source = null, Encoder $encoder = null) + { if ( ! $this->coreAvailable()) { throw new \Intervention\Image\Exception\NotSupportedException( "ImageMagick module not available with this PHP installation." @@ -21,8 +21,8 @@ class Driver extends \Intervention\Image\AbstractDriver } $this->source = $source ? $source : new Source; - $this->encoder = $encoder ? $encoder : new Encoder; - } + $this->encoder = $encoder ? $encoder : new Encoder; + } /** * Creates new image instance diff --git a/src/Intervention/Image/Imagick/Encoder.php b/src/Intervention/Image/Imagick/Encoder.php index 0166c31e..f2d6e327 100644 --- a/src/Intervention/Image/Imagick/Encoder.php +++ b/src/Intervention/Image/Imagick/Encoder.php @@ -13,7 +13,7 @@ class Encoder extends \Intervention\Image\AbstractEncoder { $format = 'jpeg'; $compression = \Imagick::COMPRESSION_JPEG; - + $imagick = $this->image->getCore(); $imagick->setFormat($format); $imagick->setImageFormat($format); diff --git a/src/Intervention/Image/Imagick/Font.php b/src/Intervention/Image/Imagick/Font.php index 1bda1d37..20d10c4b 100644 --- a/src/Intervention/Image/Imagick/Font.php +++ b/src/Intervention/Image/Imagick/Font.php @@ -72,13 +72,13 @@ class Font extends \Intervention\Image\AbstractFont // set font file if ($this->hasApplicableFontFile()) { - $draw->setFont($this->file); + $draw->setFont($this->file); } else { throw new \Intervention\Image\Exception\RuntimeException( "Font file must be provided to apply text to image." ); } - + // parse text color $color = new Color($this->color); @@ -94,7 +94,7 @@ class Font extends \Intervention\Image\AbstractFont case 'right': $align = \Imagick::ALIGN_RIGHT; break; - + default: $align = \Imagick::ALIGN_LEFT; break; diff --git a/src/Intervention/Image/Imagick/Shapes/CircleShape.php b/src/Intervention/Image/Imagick/Shapes/CircleShape.php index 765754de..9416c40f 100644 --- a/src/Intervention/Image/Imagick/Shapes/CircleShape.php +++ b/src/Intervention/Image/Imagick/Shapes/CircleShape.php @@ -18,12 +18,12 @@ class CircleShape extends EllipseShape * * @param integer $radius */ - function __construct($radius = null) + public function __construct($radius = null) { $this->width = is_numeric($radius) ? intval($radius) : $this->radius; $this->height = is_numeric($radius) ? intval($radius) : $this->radius; $this->radius = is_numeric($radius) ? intval($radius) : $this->radius; - } + } /** * Draw current circle on given image diff --git a/src/Intervention/Image/Imagick/Shapes/EllipseShape.php b/src/Intervention/Image/Imagick/Shapes/EllipseShape.php index bd3d17dc..c6ca147a 100644 --- a/src/Intervention/Image/Imagick/Shapes/EllipseShape.php +++ b/src/Intervention/Image/Imagick/Shapes/EllipseShape.php @@ -27,11 +27,11 @@ class EllipseShape extends \Intervention\Image\AbstractShape * @param integer $width * @param integer $height */ - function __construct($width = null, $height = null) + public 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 @@ -47,7 +47,7 @@ class EllipseShape extends \Intervention\Image\AbstractShape // set background $bgcolor = new Color($this->background); - $circle->setFillColor($bgcolor->getPixel()); + $circle->setFillColor($bgcolor->getPixel()); // set border if ($this->hasBorder()) { @@ -56,7 +56,7 @@ class EllipseShape extends \Intervention\Image\AbstractShape $circle->setStrokeColor($border_color->getPixel()); } - $circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360); + $circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360); $image->getCore()->drawImage($circle); diff --git a/src/Intervention/Image/Imagick/Shapes/LineShape.php b/src/Intervention/Image/Imagick/Shapes/LineShape.php index 3fc5b34e..6e22f93a 100644 --- a/src/Intervention/Image/Imagick/Shapes/LineShape.php +++ b/src/Intervention/Image/Imagick/Shapes/LineShape.php @@ -41,7 +41,7 @@ class LineShape extends \Intervention\Image\AbstractShape * @param integer $x * @param integer $y */ - function __construct($x = null, $y = null) + public function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : $this->x; $this->y = is_numeric($y) ? intval($y) : $this->y; diff --git a/src/Intervention/Image/Imagick/Shapes/RectangleShape.php b/src/Intervention/Image/Imagick/Shapes/RectangleShape.php index 9e9beb62..ad65ddf0 100644 --- a/src/Intervention/Image/Imagick/Shapes/RectangleShape.php +++ b/src/Intervention/Image/Imagick/Shapes/RectangleShape.php @@ -43,13 +43,13 @@ class RectangleShape extends \Intervention\Image\AbstractShape * @param integer $x2 * @param integer $y2 */ - function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) + public function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null) { $this->x1 = is_numeric($x1) ? intval($x1) : $this->x1; $this->y1 = is_numeric($y1) ? intval($y1) : $this->y1; $this->x2 = is_numeric($x2) ? intval($x2) : $this->x2; $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2; - } + } /** * Draw rectangle to given image at certain position @@ -65,7 +65,7 @@ class RectangleShape extends \Intervention\Image\AbstractShape // set background $bgcolor = new Color($this->background); - $rectangle->setFillColor($bgcolor->getPixel()); + $rectangle->setFillColor($bgcolor->getPixel()); // set border if ($this->hasBorder()) { @@ -74,7 +74,7 @@ class RectangleShape extends \Intervention\Image\AbstractShape $rectangle->setStrokeColor($border_color->getPixel()); } - $rectangle->rectangle($this->x1, $this->y1, $this->x2, $this->y2); + $rectangle->rectangle($this->x1, $this->y1, $this->x2, $this->y2); $image->getCore()->drawImage($rectangle); diff --git a/src/Intervention/Image/Imagick/Source.php b/src/Intervention/Image/Imagick/Source.php index d82c1ddd..19b685a8 100644 --- a/src/Intervention/Image/Imagick/Source.php +++ b/src/Intervention/Image/Imagick/Source.php @@ -70,7 +70,7 @@ class Source extends \Intervention\Image\AbstractSource $core = new \Imagick; try { - + $core->readImageBlob($binary); } catch (\ImagickException $e) { diff --git a/src/Intervention/Image/Point.php b/src/Intervention/Image/Point.php index 55837d82..bb17fb7c 100644 --- a/src/Intervention/Image/Point.php +++ b/src/Intervention/Image/Point.php @@ -24,7 +24,7 @@ class Point * @param integer $x * @param integer $y */ - public function __construct($x = null, $y = null) + public function __construct($x = null, $y = null) { $this->x = is_numeric($x) ? intval($x) : 0; $this->y = is_numeric($y) ? intval($y) : 0; diff --git a/src/Intervention/Image/Response.php b/src/Intervention/Image/Response.php index 2eb7fa26..30ca8023 100644 --- a/src/Intervention/Image/Response.php +++ b/src/Intervention/Image/Response.php @@ -32,7 +32,7 @@ class Response * @param string $format * @param integer $quality */ - public function __construct(Image $image, $format = null, $quality = null) + public function __construct(Image $image, $format = null, $quality = null) { $this->image = $image; $this->format = $format ? $format : $image->mime; @@ -51,12 +51,12 @@ class Response $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data); if (function_exists('app') && is_a($app = app(), 'Illuminate\Foundation\Application')) { - + $response = \Response::make($data); $response->header('Content-Type', $mime); } else { - + header('Content-Type: ' . $mime); $response = $data; } diff --git a/src/Intervention/Image/Size.php b/src/Intervention/Image/Size.php index 9103dab4..3c6f6f85 100644 --- a/src/Intervention/Image/Size.php +++ b/src/Intervention/Image/Size.php @@ -123,7 +123,7 @@ class Size } else { $this->height = $height; } - + if ($constraint->isFixed(Constraint::ASPECTRATIO)) { $w = intval(round($this->height * $constraint->getSize()->getRatio())); @@ -142,7 +142,7 @@ class Size } else { $this->width = $width; } - + if ($constraint->isFixed(Constraint::ASPECTRATIO)) { $h = intval(round($this->width / $constraint->getSize()->getRatio())); @@ -182,18 +182,18 @@ class Size { // create size with auto height $auto_height = clone $size; - + $auto_height->resize($this->width, null, function ($constraint) { $constraint->aspectRatio(); }); // decide which version to use if ($auto_height->fitsInto($this)) { - + $size = $auto_height; - + } else { - + // create size with auto width $auto_width = clone $size;