diff --git a/source/plg_rsfp_imageresize/vendor/composer/ClassLoader.php b/source/plg_rsfp_imageresize/vendor/composer/ClassLoader.php index 352a01b..4626994 100644 --- a/source/plg_rsfp_imageresize/vendor/composer/ClassLoader.php +++ b/source/plg_rsfp_imageresize/vendor/composer/ClassLoader.php @@ -55,10 +55,7 @@ class ClassLoader private $classMap = array(); private $classMapAuthoritative = false; private $missingClasses = array(); -<<<<<<< Updated upstream -======= private $apcuPrefix; ->>>>>>> Stashed changes public function getPrefixes() { @@ -358,13 +355,10 @@ public function findFile($class) $file = $this->findFileWithExtension($class, '.hh'); } -<<<<<<< Updated upstream -======= if (null !== $this->apcuPrefix) { apcu_add($this->apcuPrefix.$class, $file); } ->>>>>>> Stashed changes if (false === $file) { // Remember that this class does not exist. $this->missingClasses[$class] = true; diff --git a/source/plg_rsfp_imageresize/vendor/composer/autoload_classmap.php b/source/plg_rsfp_imageresize/vendor/composer/autoload_classmap.php index a3d9891..d6d4f13 100644 --- a/source/plg_rsfp_imageresize/vendor/composer/autoload_classmap.php +++ b/source/plg_rsfp_imageresize/vendor/composer/autoload_classmap.php @@ -6,5 +6,5 @@ $baseDir = dirname($vendorDir); return array( - 'Eventviva\\ImageResize' => $vendorDir . '/eventviva/php-image-resize/src/ImageResize.php', + 'Eventviva\\ImageResize' => $vendorDir . '/eventviva/php-image-resize/lib/ImageResize.php', ); diff --git a/source/plg_rsfp_imageresize/vendor/composer/autoload_static.php b/source/plg_rsfp_imageresize/vendor/composer/autoload_static.php index 00b54d8..0fb4347 100644 --- a/source/plg_rsfp_imageresize/vendor/composer/autoload_static.php +++ b/source/plg_rsfp_imageresize/vendor/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInit1f47e521aa532623ee8c604463465c1e { public static $classMap = array ( - 'Eventviva\\ImageResize' => __DIR__ . '/..' . '/eventviva/php-image-resize/src/ImageResize.php', + 'Eventviva\\ImageResize' => __DIR__ . '/..' . '/eventviva/php-image-resize/lib/ImageResize.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/source/plg_rsfp_imageresize/vendor/composer/installed.json b/source/plg_rsfp_imageresize/vendor/composer/installed.json index ff43528..dc08d04 100644 --- a/source/plg_rsfp_imageresize/vendor/composer/installed.json +++ b/source/plg_rsfp_imageresize/vendor/composer/installed.json @@ -1,17 +1,17 @@ [ { "name": "eventviva/php-image-resize", - "version": "1.5.5", - "version_normalized": "1.5.5.0", + "version": "1.6.2", + "version_normalized": "1.6.2.0", "source": { "type": "git", "url": "https://github.com/eventviva/php-image-resize.git", - "reference": "87e7200ad2e24beb9ec9862f6f2c11d93dee8838" + "reference": "8c086aad961c082939ee9e42f83f536f37b73b00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/eventviva/php-image-resize/zipball/87e7200ad2e24beb9ec9862f6f2c11d93dee8838", - "reference": "87e7200ad2e24beb9ec9862f6f2c11d93dee8838", + "url": "https://api.github.com/repos/eventviva/php-image-resize/zipball/8c086aad961c082939ee9e42f83f536f37b73b00", + "reference": "8c086aad961c082939ee9e42f83f536f37b73b00", "shasum": "" }, "require": { @@ -19,12 +19,12 @@ "ext-gd": "*", "php": ">=5.3.0" }, - "time": "2016-08-17T17:41:24+00:00", + "time": "2017-01-19T10:34:05+00:00", "type": "library", "installation-source": "dist", "autoload": { "classmap": [ - "src" + "lib" ] }, "notification-url": "https://packagist.org/downloads/", diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/.travis.yml b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/.travis.yml index b8b541b..b5ae6e7 100644 --- a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/.travis.yml +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/.travis.yml @@ -5,3 +5,4 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/Licence.md b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/Licence.md new file mode 100644 index 0000000..221339b --- /dev/null +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/Licence.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Aditya Patadia + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/README.md b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/README.md index 4d5a0db..8654ab6 100644 --- a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/README.md +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/README.md @@ -1,7 +1,7 @@ php-image-resize ================ -PHP class to resize and scale images. +PHP library to resize, scale and crop images. [![Build Status](https://travis-ci.org/eventviva/php-image-resize.svg?branch=master)](https://travis-ci.org/eventviva/php-image-resize) @@ -15,7 +15,7 @@ If using [Composer](https://getcomposer.org/), in your `composer.json` file add: ```json { "require": { - "eventviva/php-image-resize": "1.5.*" + "eventviva/php-image-resize": "1.6.*" } } ``` @@ -41,10 +41,10 @@ use \Eventviva\ImageResize; $image = new ImageResize(); ``` -Note: This library uses GD class which do not support resizing animated gif files +> Note: This library uses GD class which do not support resizing animated gif files -Usage ------ +Resize +------ To scale an image, in this case to half it's size (scaling is percentage based): @@ -53,7 +53,7 @@ $image = new ImageResize('image.jpg'); $image->scale(50); $image->save('image2.jpg') ``` - + To resize an image according to one dimension (keeping aspect ratio): ```php @@ -73,6 +73,27 @@ $image->resizeToBestFit(500, 300); $image->save('image2.jpg'); ``` +All resize functions have ```$allow_enlarge``` option which is set to false by default. +You can enable by passing ```true``` to any resize function: +```php +$image = new ImageResize('image.jpg'); +$image->resize(500, 300, $allow_enlarge = True); +$image->save('image2.jpg'); +``` + +If you are happy to handle aspect ratios yourself, you can resize directly: + +```php +$image = new ImageResize('image.jpg'); +$image->resize(800, 600); +$image->save('image2.jpg'); +``` + +This will cause your image to skew if you do not use the same width/height ratio as the source image. + +Crop +---- + To to crop an image: ```php @@ -85,16 +106,15 @@ This will scale the image to as close as it can to the passed dimensions, and th In the case of the example above, an image of 400px × 600px will be resized down to 200px × 300px, and then 50px will be taken off the top and bottom, leaving you with 200px × 200px. -If you are happy to handle aspect ratios yourself, you can resize directly: +There is also a way to define custom crop position. +You can define $x and $y in ```freecrop``` method: ```php $image = new ImageResize('image.jpg'); -$image->resize(800, 600); +$image->freecrop(200, 200, $x = 20, $y = 20); $image->save('image2.jpg'); ``` -This will cause your image to skew if you do not use the same width/height ratio as the source image. - Loading and saving images from string ------------------------------------- @@ -183,12 +203,12 @@ We're passing `null` for the image type in the example above to skip over it and Interlacing ----------- -By default, [image interlacing](http://php.net/manual/en/function.imageinterlace.php) is turned off. It can be enabled by setting `$interlace` to `1`: +By default, [image interlacing](http://php.net/manual/en/function.imageinterlace.php) is turned on. It can be disabled by setting `$interlace` to `0`: ```php $image = new ImageResize('image.jpg'); $image->scale(50); -$image->interlace = 1; +$image->interlace = 0; $image->save('image2.jpg') ``` @@ -212,3 +232,8 @@ $image ->save('image4.jpg') ; ``` + +API Doc +------- + +https://eventviva.github.io/php-image-resize/class-Eventviva.ImageResize.html diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/composer.json b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/composer.json index 479b1dd..397cb55 100644 --- a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/composer.json +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/composer.json @@ -17,6 +17,6 @@ "ext-exif": "*" }, "autoload": { - "classmap": ["src"] + "classmap": ["lib"] } } diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/src/ImageResize.php b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/lib/ImageResize.php similarity index 86% rename from source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/src/ImageResize.php rename to source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/lib/ImageResize.php index 58dbec0..f509979 100644 --- a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/src/ImageResize.php +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/lib/ImageResize.php @@ -18,8 +18,9 @@ class ImageResize public $quality_jpg = 75; public $quality_png = 0; + public $quality_truecolor = TRUE; - public $interlace = 0; + public $interlace = 1; public $source_type; @@ -96,6 +97,10 @@ public function __construct($filename) throw new \Exception('Unsupported image type'); break; } + + if (!$this->source_image) { + throw new \Exception('Could not load image'); + } return $this->resize($this->getSourceWidth(), $this->getSourceHeight()); } @@ -139,12 +144,10 @@ public function save($filename, $image_type = null, $quality = null, $permission { $image_type = $image_type ?: $this->source_type; - $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); - - imageinterlace($dest_image, $this->interlace); - switch ($image_type) { case IMAGETYPE_GIF: + $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); + $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); imagecolortransparent($dest_image, $background); imagefill($dest_image, 0, 0 , $background); @@ -152,16 +155,30 @@ public function save($filename, $image_type = null, $quality = null, $permission break; case IMAGETYPE_JPEG: + $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); + $background = imagecolorallocate($dest_image, 255, 255, 255); imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); break; case IMAGETYPE_PNG: + if (!$this->quality_truecolor && !imageistruecolor($this->source_image)) { + $dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight()); + + $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); + imagecolortransparent($dest_image, $background); + imagefill($dest_image, 0, 0 , $background); + } else { + $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); + } + imagealphablending($dest_image, false); imagesavealpha($dest_image, true); break; } + imageinterlace($dest_image, $this->interlace); + imagecopyresampled( $dest_image, $this->source_image, @@ -200,6 +217,8 @@ public function save($filename, $image_type = null, $quality = null, $permission if ($permissions) { chmod($filename, $permissions); } + + imagedestroy($dest_image); return $this; } @@ -215,7 +234,7 @@ public function getImageAsString($image_type = null, $quality = null) { $string_temp = tempnam(sys_get_temp_dir(), ''); - $this->save($string_temp, $image_type, $quality); + $this->save($string_temp , $image_type, $quality); $string = file_get_contents($string_temp); @@ -312,7 +331,7 @@ public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false) * Resizes image according to given scale (proportionally) * * @param integer|float $scale - * @return \Eventviva\ImageResize + * @return \static */ public function scale($scale) { @@ -408,6 +427,40 @@ public function crop($width, $height, $allow_enlarge = false, $position = self:: return $this; } + /** + * Crops image according to the given width, height, x and y + * + * @param integer $width + * @param integer $height + * @param integer $x + * @param integer $y + * @return \static + */ + public function freecrop($width, $height, $x = false, $y = false) + { + if($x === false or $y === false){ + return $this->crop($width, $height); + } + $this->source_x = $x; + $this->source_y = $y; + if($width > $this->getSourceWidth() - $x){ + $this->source_w = $this->getSourceWidth() - $x; + } else { + $this->source_w = $width; + } + + if($height > $this->getSourceHeight() - $y){ + $this->source_h = $this->getSourceHeight() - $y; + } else { + $this->source_h = $height; + } + + $this->dest_w = $width; + $this->dest_h = $height; + + return $this; + } + /** * Gets source width * diff --git a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/test/Test.php b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/test/Test.php index d5777ee..1e9f0f5 100644 --- a/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/test/Test.php +++ b/source/plg_rsfp_imageresize/vendor/eventviva/php-image-resize/test/Test.php @@ -1,6 +1,6 @@ assertEquals(50, $resize->getDestHeight()); } + public function testFreeCrop() + { + $image = $this->createImage(200, 100, 'png'); + $resize = new ImageResize($image); + + $resize->freecrop(50, 50 , $x = 20, $y = 20); + + $this->assertEquals(50, $resize->getDestWidth()); + $this->assertEquals(50, $resize->getDestHeight()); + } + public function testCropPosition() { $image = $this->createImage(200, 100, 'png');