Просмотр исходного кода

#298 Update Intervention Image from 2.2.2 to 2.3.7

Alex Trofimov 10 лет назад
Родитель
Сommit
067d78e5c1
55 измененных файлов с 262 добавлено и 146 удалено
  1. 8 0
      plugins/intervention-image/Intervention/Image/AbstractDecoder.php
  2. 3 0
      plugins/intervention-image/Intervention/Image/AbstractEncoder.php
  3. 1 1
      plugins/intervention-image/Intervention/Image/AbstractFont.php
  4. 1 1
      plugins/intervention-image/Intervention/Image/Commands/CircleCommand.php
  5. 1 1
      plugins/intervention-image/Intervention/Image/Commands/EllipseCommand.php
  6. 2 0
      plugins/intervention-image/Intervention/Image/Commands/IptcCommand.php
  7. 1 1
      plugins/intervention-image/Intervention/Image/Commands/LineCommand.php
  8. 1 1
      plugins/intervention-image/Intervention/Image/Commands/PolygonCommand.php
  9. 45 0
      plugins/intervention-image/Intervention/Image/Commands/PsrResponseCommand.php
  10. 1 1
      plugins/intervention-image/Intervention/Image/Commands/RectangleCommand.php
  11. 1 1
      plugins/intervention-image/Intervention/Image/Commands/ResponseCommand.php
  12. 25 0
      plugins/intervention-image/Intervention/Image/Commands/StreamCommand.php
  13. 1 1
      plugins/intervention-image/Intervention/Image/Commands/TextCommand.php
  14. 14 0
      plugins/intervention-image/Intervention/Image/File.php
  15. 2 2
      plugins/intervention-image/Intervention/Image/Gd/Commands/CropCommand.php
  16. 1 2
      plugins/intervention-image/Intervention/Image/Gd/Commands/FitCommand.php
  17. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/GetSizeCommand.php
  18. 0 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/LimitColorsCommand.php
  19. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/PickColorCommand.php
  20. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/PixelCommand.php
  21. 0 3
      plugins/intervention-image/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php
  22. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/RotateCommand.php
  23. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Commands/TrimCommand.php
  24. 12 8
      plugins/intervention-image/Intervention/Image/Gd/Decoder.php
  25. 1 3
      plugins/intervention-image/Intervention/Image/Gd/Driver.php
  26. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Font.php
  27. 1 1
      plugins/intervention-image/Intervention/Image/Gd/Shapes/CircleShape.php
  28. 2 2
      plugins/intervention-image/Intervention/Image/Gd/Shapes/EllipseShape.php
  29. 2 2
      plugins/intervention-image/Intervention/Image/Gd/Shapes/LineShape.php
  30. 2 2
      plugins/intervention-image/Intervention/Image/Gd/Shapes/PolygonShape.php
  31. 2 2
      plugins/intervention-image/Intervention/Image/Gd/Shapes/RectangleShape.php
  32. 6 15
      plugins/intervention-image/Intervention/Image/Image.php
  33. 3 2
      plugins/intervention-image/Intervention/Image/ImageServiceProvider.php
  34. 12 2
      plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel4.php
  35. 1 2
      plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php
  36. 42 0
      plugins/intervention-image/Intervention/Image/ImageServiceProviderLeague.php
  37. 31 0
      plugins/intervention-image/Intervention/Image/ImageServiceProviderLumen.php
  38. 2 2
      plugins/intervention-image/Intervention/Image/Imagick/Commands/CropCommand.php
  39. 3 3
      plugins/intervention-image/Intervention/Image/Imagick/Commands/FillCommand.php
  40. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/FitCommand.php
  41. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/GetSizeCommand.php
  42. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/PickColorCommand.php
  43. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/PixelCommand.php
  44. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/RotateCommand.php
  45. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Commands/TrimCommand.php
  46. 7 4
      plugins/intervention-image/Intervention/Image/Imagick/Decoder.php
  47. 2 4
      plugins/intervention-image/Intervention/Image/Imagick/Driver.php
  48. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Font.php
  49. 1 1
      plugins/intervention-image/Intervention/Image/Imagick/Shapes/CircleShape.php
  50. 2 2
      plugins/intervention-image/Intervention/Image/Imagick/Shapes/EllipseShape.php
  51. 2 2
      plugins/intervention-image/Intervention/Image/Imagick/Shapes/LineShape.php
  52. 2 2
      plugins/intervention-image/Intervention/Image/Imagick/Shapes/PolygonShape.php
  53. 2 2
      plugins/intervention-image/Intervention/Image/Imagick/Shapes/RectangleShape.php
  54. 1 1
      plugins/intervention-image/Intervention/Image/Size.php
  55. 0 53
      plugins/intervention-image/README.md

+ 8 - 0
plugins/intervention-image/Intervention/Image/AbstractDecoder.php

@@ -216,6 +216,10 @@ abstract class AbstractDecoder
      */
     public function isBase64()
     {
+        if (!is_string($this->data)) {
+            return false;
+        }
+
         return base64_encode(base64_decode($this->data)) === $this->data;
     }
 
@@ -238,6 +242,10 @@ abstract class AbstractDecoder
      */
     private function decodeDataUrl($data_url)
     {
+        if (!is_string($data_url)) {
+            return null;
+        }
+
         $pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)$/";
         preg_match($pattern, $data_url, $matches);
 

+ 3 - 0
plugins/intervention-image/Intervention/Image/AbstractEncoder.php

@@ -135,6 +135,7 @@ abstract class AbstractEncoder
                 break;
 
             case 'ico':
+            case 'image/x-ico':
             case 'image/x-icon':
             case 'image/vnd.microsoft.icon':
                 $this->result = $this->processIco();
@@ -151,6 +152,8 @@ abstract class AbstractEncoder
                 );
         }
 
+        $this->setImage(null);
+
         return $image->setEncoded($this->result);
     }
 

+ 1 - 1
plugins/intervention-image/Intervention/Image/AbstractFont.php

@@ -202,7 +202,7 @@ abstract class AbstractFont
     /**
      * Set path to font file
      *
-     * @param  string $align
+     * @param  string $file
      * @return void
      */
     public function file($file)

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/CircleCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class CircleCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/EllipseCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class EllipseCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 2 - 0
plugins/intervention-image/Intervention/Image/Commands/IptcCommand.php

@@ -36,9 +36,11 @@ class IptcCommand extends AbstractCommand
                 $data['Keywords'] = isset($iptc["2#025"][0]) ? $iptc["2#025"] : null;
                 $data['SpecialInstructions'] = isset($iptc["2#040"][0]) ? $iptc["2#040"][0] : null;
                 $data['CreationDate'] = isset($iptc["2#055"][0]) ? $iptc["2#055"][0] : null;
+                $data['CreationTime'] = isset($iptc["2#060"][0]) ? $iptc["2#060"][0] : null;
                 $data['AuthorByline'] = isset($iptc["2#080"][0]) ? $iptc["2#080"][0] : null;
                 $data['AuthorTitle'] = isset($iptc["2#085"][0]) ? $iptc["2#085"][0] : null;
                 $data['City'] = isset($iptc["2#090"][0]) ? $iptc["2#090"][0] : null;
+                $data['SubLocation'] = isset($iptc["2#092"][0]) ? $iptc["2#092"][0] : null;
                 $data['State'] = isset($iptc["2#095"][0]) ? $iptc["2#095"][0] : null;
                 $data['Country'] = isset($iptc["2#101"][0]) ? $iptc["2#101"][0] : null;
                 $data['OTR'] = isset($iptc["2#103"][0]) ? $iptc["2#103"][0] : null;

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/LineCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class LineCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/PolygonCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class PolygonCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 45 - 0
plugins/intervention-image/Intervention/Image/Commands/PsrResponseCommand.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace Intervention\Image\Commands;
+
+use GuzzleHttp\Psr7\Response;
+
+class PsrResponseCommand extends AbstractCommand
+{
+    /**
+     * Builds PSR7 compatible response. May replace "response" command in
+     * some future.
+     *
+     * Method will generate binary stream and put it inside PSR-7
+     * ResponseInterface. Following code can be optimized using native php
+     * streams and more "clean" streaming, however drivers has to be updated
+     * first.
+     *
+     * @param  \Intervention\Image\Image $image
+     * @return boolean
+     */
+    public function execute($image)
+    {
+        $format = $this->argument(0)->value();
+        $quality = $this->argument(1)->between(0, 100)->value();
+
+        //Encoded property will be populated at this moment
+        $stream = $image->stream($format, $quality);
+
+        $mimetype = finfo_buffer(
+            finfo_open(FILEINFO_MIME_TYPE),
+            $image->getEncoded()
+        );
+
+        $this->setOutput(new Response(
+            200,
+            array(
+                'Content-Type'   => $mimetype,
+                'Content-Length' => strlen($image->getEncoded())
+            ),
+            $stream
+        ));
+
+        return true;
+    }
+}

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/RectangleCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class RectangleCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/ResponseCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Intervention\Image\Response;
+use Intervention\Image\Response;
 
 class ResponseCommand extends AbstractCommand
 {

+ 25 - 0
plugins/intervention-image/Intervention/Image/Commands/StreamCommand.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace Intervention\Image\Commands;
+
+class StreamCommand extends AbstractCommand
+{
+    /**
+     * Builds PSR7 stream based on image data. Method uses Guzzle PSR7
+     * implementation as easiest choice.
+     *
+     * @param  \Intervention\Image\Image $image
+     * @return boolean
+     */
+    public function execute($image)
+    {
+        $format = $this->argument(0)->value();
+        $quality = $this->argument(1)->between(0, 100)->value();
+
+        $this->setOutput(\GuzzleHttp\Psr7\stream_for(
+            $image->encode($format, $quality)->getEncoded()
+        ));
+
+        return true;
+    }
+}

+ 1 - 1
plugins/intervention-image/Intervention/Image/Commands/TextCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Commands;
 
-use \Closure;
+use Closure;
 
 class TextCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 14 - 0
plugins/intervention-image/Intervention/Image/File.php

@@ -75,4 +75,18 @@ class File
         return false;
     }
 
+    /**
+     * Get fully qualified path
+     *
+     * @return string
+     */
+    public function basePath()
+    {
+        if ($this->dirname && $this->basename) {
+            return ($this->dirname .'/'. $this->basename);
+        }
+
+        return null;
+    }
+
 }

+ 2 - 2
plugins/intervention-image/Intervention/Image/Gd/Commands/CropCommand.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Point;
-use \Intervention\Image\Size;
+use Intervention\Image\Point;
+use Intervention\Image\Size;
 
 class CropCommand extends ResizeCommand
 {

+ 1 - 2
plugins/intervention-image/Intervention/Image/Gd/Commands/FitCommand.php

@@ -2,8 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Point;
-use \Intervention\Image\Size;
+use Intervention\Image\Size;
 
 class FitCommand extends ResizeCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/GetSizeCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Size;
+use Intervention\Image\Size;
 
 class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 0 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/LimitColorsCommand.php

@@ -2,7 +2,6 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use Intervention\Image\Gd\Color;
 
 class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/PickColorCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Gd\Color;
 
 class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/PixelCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Gd\Color;
 
 class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 0 - 3
plugins/intervention-image/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php

@@ -2,9 +2,6 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Point;
-use \Intervention\Image\Size;
-
 class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
 {
     /**

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/RotateCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Gd\Color;
 
 class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Commands/TrimCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Commands;
 
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Gd\Color;
 
 class TrimCommand extends ResizeCommand
 {

+ 12 - 8
plugins/intervention-image/Intervention/Image/Gd/Decoder.php

@@ -2,8 +2,7 @@
 
 namespace Intervention\Image\Gd;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Size;
+use Intervention\Image\Image;
 
 class Decoder extends \Intervention\Image\AbstractDecoder
 {
@@ -26,18 +25,15 @@ class Decoder extends \Intervention\Image\AbstractDecoder
         // define core
         switch ($info[2]) {
             case IMAGETYPE_PNG:
-                $core = imagecreatefrompng($path);
-                $this->gdResourceToTruecolor($core);
+                $core = @imagecreatefrompng($path);
                 break;
 
             case IMAGETYPE_JPEG:
-                $core = imagecreatefromjpeg($path);
-                $this->gdResourceToTruecolor($core);
+                $core = @imagecreatefromjpeg($path);
                 break;
 
             case IMAGETYPE_GIF:
-                $core = imagecreatefromgif($path);
-                $this->gdResourceToTruecolor($core);
+                $core = @imagecreatefromgif($path);
                 break;
 
             default:
@@ -46,6 +42,14 @@ class Decoder extends \Intervention\Image\AbstractDecoder
                 );
         }
 
+        if ($core === false) {
+            throw new \Intervention\Image\Exception\NotReadableException(
+                "Unable to read image from file ({$path})."
+            );
+        }
+
+        $this->gdResourceToTruecolor($core);
+
         // build image
         $image = $this->initFromGdResource($core);
         $image->mime = $info['mime'];

+ 1 - 3
plugins/intervention-image/Intervention/Image/Gd/Driver.php

@@ -2,8 +2,6 @@
 
 namespace Intervention\Image\Gd;
 
-use \Intervention\Image\Size;
-
 class Driver extends \Intervention\Image\AbstractDriver
 {
     /**
@@ -36,7 +34,7 @@ class Driver extends \Intervention\Image\AbstractDriver
     {
         // create empty resource
         $core = imagecreatetruecolor($width, $height);
-        $image = new \Intervention\Image\Image(new self, $core);
+        $image = new \Intervention\Image\Image(new static, $core);
 
         // set background color
         $background = new Color($background);

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Font.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd;
 
-use \Intervention\Image\Image;
+use Intervention\Image\Image;
 
 class Font extends \Intervention\Image\AbstractFont
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Gd/Shapes/CircleShape.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Gd\Shapes;
 
-use \Intervention\Image\Image;
+use Intervention\Image\Image;
 
 class CircleShape extends EllipseShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Gd/Shapes/EllipseShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Gd\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Gd\Color;
 
 class EllipseShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Gd/Shapes/LineShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Gd\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Gd\Color;
 
 class LineShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Gd/Shapes/PolygonShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Gd\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Gd\Color;
 
 class PolygonShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Gd/Shapes/RectangleShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Gd\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Gd\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Gd\Color;
 
 class RectangleShape extends \Intervention\Image\AbstractShape
 {

+ 6 - 15
plugins/intervention-image/Intervention/Image/Image.php

@@ -2,6 +2,9 @@
 
 namespace Intervention\Image;
 
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
+
 /**
  * @method \Intervention\Image\Image backup(string $name = 'default')                                                                                                     Backups current image state as fallback for reset method under an optional name. Overwrites older state on every call, unless a different name is passed.
  * @method \Intervention\Image\Image blur(integer $amount = 1)                                                                                                            Apply a gaussian blur filter with a optional amount on the current image. Use values between 0 and 100.
@@ -45,6 +48,8 @@ namespace Intervention\Image;
  * @method \Intervention\Image\Image text(string $text, integer $x = 0, integer $y = 0, \Closure $callback = null)                                                        Write a text string to the current image at an optional x,y basepoint position. You can define more details like font-size, font-file and alignment via a callback as the fourth parameter.
  * @method \Intervention\Image\Image trim(string $base = 'top-left', array $away = array('top', 'bottom', 'left', 'right'), integer $tolerance = 0, integer $feather = 0) Trim away image space in given color. Define an optional base to pick a color at a certain position and borders that should be trimmed away. You can also set an optional tolerance level, to trim similar colors and add a feathering border around the trimed image.
  * @method \Intervention\Image\Image widen(integer $width, \Closure $callback = null)                                                                                     Resizes the current image to new width, constraining aspect ratio. Pass an optional Closure callback as third parameter, to apply additional constraints like preventing possible upsizing.
+ * @method StreamInterface           stream(string $format = null, integer $quality = 90)                                                                                 Build PSR-7 compatible StreamInterface with current image in given format and quality.
+ * @method ResponseInterface         psrResponse(string $format = null, integer $quality = 90)                                                                            Build PSR-7 compatible ResponseInterface with current image in given format and quality.
  */
 class Image extends File
 {
@@ -263,7 +268,7 @@ class Image extends File
      */
     public function isEncoded()
     {
-        return ! is_null($this->encoded);
+        return ! empty($this->encoded);
     }
 
     /**
@@ -338,20 +343,6 @@ class Image extends File
         return $this->mime;
     }
 
-    /**
-     * Get fully qualified path to image
-     *
-     * @return string
-     */
-    public function basePath()
-    {
-        if ($this->dirname && $this->basename) {
-            return ($this->dirname .'/'. $this->basename);
-        }
-
-        return null;
-    }
-
     /**
      * Returns encoded image data in string conversion
      *

+ 3 - 2
plugins/intervention-image/Intervention/Image/ImageServiceProvider.php

@@ -2,7 +2,6 @@
 
 namespace Intervention\Image;
 
-use Illuminate\Foundation\Application;
 use Illuminate\Support\ServiceProvider;
 
 class ImageServiceProvider extends ServiceProvider
@@ -61,7 +60,9 @@ class ImageServiceProvider extends ServiceProvider
      */
     private function getProvider()
     {
-        if (version_compare(Application::VERSION, '5.0', '<')) {
+        if ($this->app instanceof \Laravel\Lumen\Application) {
+            $provider = '\Intervention\Image\ImageServiceProviderLumen';
+        } elseif (version_compare(\Illuminate\Foundation\Application::VERSION, '5.0', '<')) {
             $provider = '\Intervention\Image\ImageServiceProviderLaravel4';
         } else {
             $provider = '\Intervention\Image\ImageServiceProviderLaravel5';

+ 12 - 2
plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel4.php

@@ -56,11 +56,21 @@ class ImageServiceProviderLaravel4 extends ServiceProvider
                     // define template callback
                     $callback = $config->get("imagecache::templates.{$template}");
 
-                    if (is_callable($callback)) {
+                    if (is_callable($callback) || class_exists($callback)) {
 
                         // image manipulation based on callback
                         $content = $app['image']->cache(function ($image) use ($image_path, $callback) {
-                            return $callback($image->make($image_path));
+                            
+                            switch (true) {
+                                case is_callable($callback):
+                                    return $callback($image->make($image_path));
+                                    break;
+                                
+                                case class_exists($callback):
+                                    return $image->make($image_path)->filter(new $callback);
+                                    break;
+                            }
+
                         }, $config->get('imagecache::lifetime'));
 
                     } else {

+ 1 - 2
plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php

@@ -3,7 +3,6 @@
 namespace Intervention\Image;
 
 use Illuminate\Support\ServiceProvider;
-use Illuminate\Http\Response as IlluminateResponse;
 
 class ImageServiceProviderLaravel5 extends ServiceProvider
 {
@@ -78,7 +77,7 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
         // imagecache route
         if (is_string(config('imagecache.route'))) {
 
-            $filename_pattern = '[ \w\\.\\/\\-]+';
+            $filename_pattern = '[ \w\\.\\/\\-\\@]+';
 
             // route to access template applied image file
             $app['router']->get(config('imagecache.route').'/{template}/{filename}', array(

+ 42 - 0
plugins/intervention-image/Intervention/Image/ImageServiceProviderLeague.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace Intervention\Image;
+
+use League\Container\ServiceProvider\AbstractServiceProvider;
+
+class ImageServiceProviderLeague extends AbstractServiceProvider
+{
+    /**
+     * @var array $config
+     */
+    protected $config;
+
+    /**
+     * @var array $provides
+     */
+    protected $provides = [
+        'Intervention\Image\ImageManager'
+    ];
+
+    /**
+     * Constructor.
+     *
+     * @param array $config
+     */
+    public function __construct($config = array())
+    {
+        $this->config = $config;
+    }
+
+    /**
+     * Register the server provider.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        $this->getContainer()->share('Intervention\Image\ImageManager', function () {
+            return new ImageManager($this->config);
+        });
+    }
+}

+ 31 - 0
plugins/intervention-image/Intervention/Image/ImageServiceProviderLumen.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace Intervention\Image;
+
+use Illuminate\Support\ServiceProvider;
+
+class ImageServiceProviderLumen extends ServiceProvider
+{
+    /**
+     * Register the service provider.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        $app = $this->app;
+
+        // merge default config
+        $this->mergeConfigFrom(
+          __DIR__.'/../../config/config.php',
+          'image'
+        );
+
+        // create image
+        $app['image'] = $app->share(function ($app) {
+            return new ImageManager($app['config']->get('image'));
+        });
+
+        $app->alias('image', 'Intervention\Image\ImageManager');
+    }
+}

+ 2 - 2
plugins/intervention-image/Intervention/Image/Imagick/Commands/CropCommand.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Point;
-use \Intervention\Image\Size;
+use Intervention\Image\Point;
+use Intervention\Image\Size;
 
 class CropCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 3 - 3
plugins/intervention-image/Intervention/Image/Imagick/Commands/FillCommand.php

@@ -2,9 +2,9 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Imagick\Decoder;
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Imagick\Decoder;
+use Intervention\Image\Imagick\Color;
 
 class FillCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/FitCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Size;
+use Intervention\Image\Size;
 
 class FitCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/GetSizeCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Size;
+use Intervention\Image\Size;
 
 class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/PickColorCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Imagick\Color;
 
 class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/PixelCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Imagick\Color;
 
 class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/RotateCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Imagick\Color;
 
 class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Commands/TrimCommand.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Commands;
 
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Imagick\Color;
 
 class TrimCommand extends \Intervention\Image\Commands\AbstractCommand
 {

+ 7 - 4
plugins/intervention-image/Intervention/Image/Imagick/Decoder.php

@@ -2,8 +2,7 @@
 
 namespace Intervention\Image\Imagick;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Size;
+use Intervention\Image\Image;
 
 class Decoder extends \Intervention\Image\AbstractDecoder
 {
@@ -24,7 +23,9 @@ class Decoder extends \Intervention\Image\AbstractDecoder
 
         } catch (\ImagickException $e) {
             throw new \Intervention\Image\Exception\NotReadableException(
-                "Unable to read image from path ({$path})."
+                "Unable to read image from path ({$path}).",
+                0,
+                $e
             );
         }
 
@@ -82,7 +83,9 @@ class Decoder extends \Intervention\Image\AbstractDecoder
 
         } catch (\ImagickException $e) {
             throw new \Intervention\Image\Exception\NotReadableException(
-                "Unable to read image from binary data."
+                "Unable to read image from binary data.",
+                0,
+                $e
             );
         }
 

+ 2 - 4
plugins/intervention-image/Intervention/Image/Imagick/Driver.php

@@ -2,8 +2,6 @@
 
 namespace Intervention\Image\Imagick;
 
-use \Intervention\Image\Size;
-
 class Driver extends \Intervention\Image\AbstractDriver
 {
     /**
@@ -40,11 +38,11 @@ class Driver extends \Intervention\Image\AbstractDriver
         $core = new \Imagick;
         $core->newImage($width, $height, $background->getPixel(), 'png');
         $core->setType(\Imagick::IMGTYPE_UNDEFINED);
-        $core->setImagetype(\Imagick::IMGTYPE_UNDEFINED);
+        $core->setImageType(\Imagick::IMGTYPE_UNDEFINED);
         $core->setColorspace(\Imagick::COLORSPACE_UNDEFINED);
 
         // build image
-        $image = new \Intervention\Image\Image(new self, $core);
+        $image = new \Intervention\Image\Image(new static, $core);
 
         return $image;
     }

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Font.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick;
 
-use \Intervention\Image\Image;
+use Intervention\Image\Image;
 
 class Font extends \Intervention\Image\AbstractFont
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Imagick/Shapes/CircleShape.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image\Imagick\Shapes;
 
-use \Intervention\Image\Image;
+use Intervention\Image\Image;
 
 class CircleShape extends EllipseShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Imagick/Shapes/EllipseShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Imagick\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Imagick\Color;
 
 class EllipseShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Imagick/Shapes/LineShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Imagick\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Imagick\Color;
 
 class LineShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Imagick/Shapes/PolygonShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Imagick\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Imagick\Color;
 
 class PolygonShape extends \Intervention\Image\AbstractShape
 {

+ 2 - 2
plugins/intervention-image/Intervention/Image/Imagick/Shapes/RectangleShape.php

@@ -2,8 +2,8 @@
 
 namespace Intervention\Image\Imagick\Shapes;
 
-use \Intervention\Image\Image;
-use \Intervention\Image\Imagick\Color;
+use Intervention\Image\Image;
+use Intervention\Image\Imagick\Color;
 
 class RectangleShape extends \Intervention\Image\AbstractShape
 {

+ 1 - 1
plugins/intervention-image/Intervention/Image/Size.php

@@ -2,7 +2,7 @@
 
 namespace Intervention\Image;
 
-use \Closure;
+use Closure;
 
 class Size
 {

+ 0 - 53
plugins/intervention-image/README.md

@@ -1,53 +0,0 @@
-# Intervention Image
-
-Intervention Image is a **PHP image handling and manipulation** library providing an easier and expressive way to create, edit, and compose images. The package includes ServiceProviders and Facades for easy **Laravel** integration.
-
-[![Build Status](https://travis-ci.org/Intervention/image.png?branch=master)](https://travis-ci.org/Intervention/image)
-
-## Requirements
-
-- PHP >=5.3
-- Fileinfo Extension
-
-## Supported Image Libraries
-
-- GD Library (>=2.0)
-- Imagick PHP extension (>=6.5.7)
-
-## Getting started
-
-- [Installation](http://image.intervention.io/getting_started/installation)
-- [Laravel Framework Integration](http://image.intervention.io/getting_started/installation#laravel)
-- [Official Documentation](http://image.intervention.io/)
-
-## Code Examples
-
-```php
-// open an image file
-$img = Image::make('public/foo.jpg');
-
-// resize image instance
-$img->resize(320, 240);
-
-// insert a watermark
-$img->insert('public/watermark.png');
-
-// save image in desired format
-$img->save('public/bar.jpg');
-```
-
-Refer to the [documentation](http://image.intervention.io/) to learn more about Intervention Image.
-
-## Contributing
-
-Contributions to the Intervention Image library are welcome. Please note the following guidelines before submiting your pull request.
-
-- Follow [PSR-2](http://www.php-fig.org/psr/psr-2/) coding standards.
-- Write tests for new functions and added features
-- API calls should work consistently with both GD and Imagick drivers
-
-## License
-
-Intervention Image is licensed under the [MIT License](http://opensource.org/licenses/MIT).
-
-Copyright 2014 [Oliver Vogel](http://olivervogel.net/)