├── .gitignore
├── _build
├── config
│ ├── categories.php
│ └── current.project.php
├── build.config.php
├── data
│ └── transport.settings.php
└── validators
│ └── resizer.validator.php
└── core
└── components
└── resizer
├── model
├── vendor
│ ├── oo12
│ │ └── reductionist
│ │ │ ├── README.md
│ │ │ ├── src
│ │ │ └── Reductionist
│ │ │ │ ├── resources
│ │ │ │ ├── FiraSansOT-Medium.otf
│ │ │ │ └── SIL Open Font License.txt
│ │ │ │ ├── Gmagick
│ │ │ │ ├── RImage.php
│ │ │ │ └── RImagine.php
│ │ │ │ ├── Imagick
│ │ │ │ ├── RImagine.php
│ │ │ │ └── RImage.php
│ │ │ │ └── Image
│ │ │ │ └── RAbstractImage.php
│ │ │ ├── composer.json
│ │ │ └── LICENSE
│ ├── imagine
│ │ └── imagine
│ │ │ ├── lib
│ │ │ └── Imagine
│ │ │ │ ├── resources
│ │ │ │ ├── Adobe
│ │ │ │ │ └── CMYK
│ │ │ │ │ │ └── USWebUncoated.icc
│ │ │ │ ├── color.org
│ │ │ │ │ └── sRGB_IEC61966-2-1_black_scaled.icc
│ │ │ │ └── colormanagement.org
│ │ │ │ │ └── ISOcoated_v2_grey1c_bas.ICC
│ │ │ │ ├── Exception
│ │ │ │ ├── Exception.php
│ │ │ │ ├── RuntimeException.php
│ │ │ │ ├── OutOfBoundsException.php
│ │ │ │ ├── InvalidArgumentException.php
│ │ │ │ └── NotSupportedException.php
│ │ │ │ ├── Image
│ │ │ │ ├── ProfileInterface.php
│ │ │ │ ├── Metadata
│ │ │ │ │ ├── DefaultMetadataReader.php
│ │ │ │ │ ├── MetadataReaderInterface.php
│ │ │ │ │ ├── MetadataBag.php
│ │ │ │ │ ├── ExifMetadataReader.php
│ │ │ │ │ └── AbstractMetadataReader.php
│ │ │ │ ├── FontInterface.php
│ │ │ │ ├── AbstractImagine.php
│ │ │ │ ├── AbstractLayers.php
│ │ │ │ ├── PointInterface.php
│ │ │ │ ├── Profile.php
│ │ │ │ ├── AbstractFont.php
│ │ │ │ ├── Point
│ │ │ │ │ └── Center.php
│ │ │ │ ├── Point.php
│ │ │ │ ├── ImagineInterface.php
│ │ │ │ ├── BoxInterface.php
│ │ │ │ ├── Palette
│ │ │ │ │ ├── Color
│ │ │ │ │ │ ├── ColorInterface.php
│ │ │ │ │ │ ├── Gray.php
│ │ │ │ │ │ ├── RGB.php
│ │ │ │ │ │ └── CMYK.php
│ │ │ │ │ ├── PaletteInterface.php
│ │ │ │ │ ├── Grayscale.php
│ │ │ │ │ ├── CMYK.php
│ │ │ │ │ ├── RGB.php
│ │ │ │ │ └── ColorParser.php
│ │ │ │ ├── Box.php
│ │ │ │ ├── LayersInterface.php
│ │ │ │ ├── AbstractImage.php
│ │ │ │ ├── ImageInterface.php
│ │ │ │ └── ManipulatorInterface.php
│ │ │ │ ├── Filter
│ │ │ │ ├── Basic
│ │ │ │ │ ├── Copy.php
│ │ │ │ │ ├── Strip.php
│ │ │ │ │ ├── FlipVertically.php
│ │ │ │ │ ├── FlipHorizontally.php
│ │ │ │ │ ├── ApplyMask.php
│ │ │ │ │ ├── Fill.php
│ │ │ │ │ ├── Save.php
│ │ │ │ │ ├── Show.php
│ │ │ │ │ ├── Resize.php
│ │ │ │ │ ├── Rotate.php
│ │ │ │ │ ├── Paste.php
│ │ │ │ │ ├── Crop.php
│ │ │ │ │ ├── Thumbnail.php
│ │ │ │ │ └── Autorotate.php
│ │ │ │ ├── FilterInterface.php
│ │ │ │ ├── ImagineAware.php
│ │ │ │ └── Transformation.php
│ │ │ │ ├── Gd
│ │ │ │ ├── Font.php
│ │ │ │ ├── Effects.php
│ │ │ │ ├── Layers.php
│ │ │ │ └── Imagine.php
│ │ │ │ ├── Gmagick
│ │ │ │ ├── Font.php
│ │ │ │ ├── Effects.php
│ │ │ │ ├── Imagine.php
│ │ │ │ └── Layers.php
│ │ │ │ ├── Effects
│ │ │ │ └── EffectsInterface.php
│ │ │ │ ├── Imagick
│ │ │ │ ├── Font.php
│ │ │ │ ├── Effects.php
│ │ │ │ └── Imagine.php
│ │ │ │ └── Draw
│ │ │ │ └── DrawerInterface.php
│ │ │ ├── composer.json
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ └── CHANGELOG.md
│ ├── autoload.php
│ └── composer
│ │ ├── autoload_namespaces.php
│ │ └── autoload_real.php
├── composer.json
└── resizer.class.php
├── docs
├── readme.txt
└── changelog.txt
└── lexicon
└── en
└── default.inc.php
/.gitignore:
--------------------------------------------------------------------------------
1 | .gitignore
2 | no-git/*
3 | .DS_Store
4 | update
5 | composer.lock
6 |
--------------------------------------------------------------------------------
/_build/config/categories.php:
--------------------------------------------------------------------------------
1 | 'Resizer',
4 | );
5 | return $cats;
6 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/README.md:
--------------------------------------------------------------------------------
1 | Reductionist
2 | ==========
3 |
4 | For the moment please see the [Resizer documentation](https://github.com/oo12/Resizer). Resizer is a MODX wrapper for Reductionist.
5 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/resources/Adobe/CMYK/USWebUncoated.icc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modxcms/Resizer/HEAD/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/resources/Adobe/CMYK/USWebUncoated.icc
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/resources/FiraSansOT-Medium.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modxcms/Resizer/HEAD/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/resources/FiraSansOT-Medium.otf
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/oo12/reductionist/src'),
10 | 'Imagine' => array($vendorDir . '/imagine/imagine/lib'),
11 | );
12 |
--------------------------------------------------------------------------------
/_build/config/current.project.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Exception;
13 |
14 | /**
15 | * Imagine-specific exception
16 | */
17 | interface Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "oo12/reductionist",
3 | "description": "A simple, modern phpThumb",
4 | "homepage": "https://github.com/oo12/Reductionist",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Jason Grant",
9 | "email": "dadima@gmail.com"
10 | }
11 | ],
12 | "require": {
13 | "imagine/imagine": "dev-develop"
14 | },
15 | "autoload": {
16 | "psr-0": {
17 | "Reductionist": "src/"
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Exception/RuntimeException.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Exception;
13 |
14 | /**
15 | * Imagine-specific runtime exception
16 | */
17 | class RuntimeException extends \RuntimeException implements Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Exception/OutOfBoundsException.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Exception;
13 |
14 | /**
15 | * Imagine-specific out of bounds exception
16 | */
17 | class OutOfBoundsException extends \OutOfBoundsException implements Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Exception/InvalidArgumentException.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Exception;
13 |
14 | /**
15 | * Imagine-specific invalid argument exception
16 | */
17 | class InvalidArgumentException extends \InvalidArgumentException implements Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Exception/NotSupportedException.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Exception;
13 |
14 | /**
15 | * Should be used when a driver does not support an operation.
16 | */
17 | class NotSupportedException extends RuntimeException implements Exception
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/_build/build.config.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | interface ProfileInterface
15 | {
16 | /**
17 | * Returns the name of the profile
18 | *
19 | * @return String
20 | */
21 | public function name();
22 |
23 | /**
24 | * Returns the profile data
25 | *
26 | * @return String
27 | */
28 | public function data();
29 | }
30 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Copy.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Filter\FilterInterface;
15 | use Imagine\Image\ImageInterface;
16 |
17 | /**
18 | * A copy filter
19 | */
20 | class Copy implements FilterInterface
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | public function apply(ImageInterface $image)
26 | {
27 | return $image->copy();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Strip.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Filter\FilterInterface;
16 |
17 | /**
18 | * A strip filter
19 | */
20 | class Strip implements FilterInterface
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | public function apply(ImageInterface $image)
26 | {
27 | return $image->strip();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/FlipVertically.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Filter\FilterInterface;
16 |
17 | /**
18 | * A "flip vertically" filter
19 | */
20 | class FlipVertically implements FilterInterface
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | public function apply(ImageInterface $image)
26 | {
27 | return $image->flipVertically();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/FlipHorizontally.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Filter\FilterInterface;
16 |
17 | /**
18 | * A "flip horizontally" filter
19 | */
20 | class FlipHorizontally implements FilterInterface
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | public function apply(ImageInterface $image)
26 | {
27 | return $image->flipHorizontally();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/FilterInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter;
13 |
14 | use Imagine\Image\ImageInterface;
15 |
16 | /**
17 | * Interface for imagine filters
18 | */
19 | interface FilterInterface
20 | {
21 | /**
22 | * Applies scheduled transformation to ImageInterface instance
23 | * Returns processed ImageInterface instance
24 | *
25 | * @param ImageInterface $image
26 | *
27 | * @return ImageInterface
28 | */
29 | public function apply(ImageInterface $image);
30 | }
31 |
--------------------------------------------------------------------------------
/_build/data/transport.settings.php:
--------------------------------------------------------------------------------
1 | ', '', $o);
17 | $o = trim($o);
18 | return $o;
19 | }
20 | }
21 | /* @var $modx modX */
22 | /* @var $sources array */
23 | /* @var xPDOObject[] $systemSettings */
24 |
25 |
26 | $systemSettings = array();
27 |
28 | $systemSettings[0] = $modx->newObject('modSystemSetting');
29 | $systemSettings[0]->fromArray(array (
30 | 'key' => 'resizer.graphics_library',
31 | 'value' => '2',
32 | 'xtype' => 'textfield',
33 | 'namespace' => 'resizer',
34 | 'area' => 'resizer',
35 | ), '', true, true);
36 | return $systemSettings;
37 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Metadata/DefaultMetadataReader.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Metadata;
13 |
14 | /**
15 | * Default metadata reader
16 | */
17 | class DefaultMetadataReader extends AbstractMetadataReader
18 | {
19 | /**
20 | * {@inheritdoc}
21 | */
22 | protected function extractFromFile($file)
23 | {
24 | return array();
25 | }
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected function extractFromData($data)
31 | {
32 | return array();
33 | }
34 |
35 | /**
36 | * {@inheritdoc}
37 | */
38 | protected function extractFromStream($resource)
39 | {
40 | return array();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/ApplyMask.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Filter\FilterInterface;
15 | use Imagine\Image\ImageInterface;
16 |
17 | /**
18 | * An apply mask filter
19 | */
20 | class ApplyMask implements FilterInterface
21 | {
22 | /**
23 | * @var ImageInterface
24 | */
25 | private $mask;
26 |
27 | /**
28 | * @param ImageInterface $mask
29 | */
30 | public function __construct(ImageInterface $mask)
31 | {
32 | $this->mask = $mask;
33 | }
34 |
35 | /**
36 | * {@inheritdoc}
37 | */
38 | public function apply(ImageInterface $image)
39 | {
40 | return $image->applyMask($this->mask);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Fill.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Filter\FilterInterface;
15 | use Imagine\Image\Fill\FillInterface;
16 | use Imagine\Image\ImageInterface;
17 |
18 | /**
19 | * A fill filter
20 | */
21 | class Fill implements FilterInterface
22 | {
23 | /**
24 | * @var FillInterface
25 | */
26 | private $fill;
27 |
28 | /**
29 | * @param FillInterface $fill
30 | */
31 | public function __construct(FillInterface $fill)
32 | {
33 | $this->fill = $fill;
34 | }
35 |
36 | /**
37 | * {@inheritdoc}
38 | */
39 | public function apply(ImageInterface $image)
40 | {
41 | return $image->fill($this->fill);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Reductionist
4 | Copyright (c) 2014 Jason Grant
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "imagine/imagine",
3 | "description": "Image processing for PHP 5.3",
4 | "keywords": [
5 | "image manipulation",
6 | "image processing",
7 | "drawing",
8 | "graphics"
9 | ],
10 | "homepage": "http://imagine.readthedocs.org/",
11 | "license": "MIT",
12 | "authors": [
13 | {
14 | "name": "Bulat Shakirzyanov",
15 | "email": "mallluhuct@gmail.com",
16 | "homepage": "http://avalanche123.com"
17 | }
18 | ],
19 | "config": {
20 | "bin-dir": "bin"
21 | },
22 | "require": {
23 | "php": ">=5.3.2"
24 | },
25 | "require-dev": {
26 | "sami/sami": "dev-master"
27 | },
28 | "suggest": {
29 | "ext-gd": "to use the GD implementation",
30 | "ext-imagick": "to use the Imagick implementation",
31 | "ext-gmagick": "to use the Gmagick implementation"
32 | },
33 | "autoload": {
34 | "psr-0": {
35 | "Imagine": "lib/"
36 | }
37 | },
38 | "extra": {
39 | "branch-alias": {
40 | "dev-develop": "0.6-dev"
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/FontInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Image\Palette\Color\ColorInterface;
15 |
16 | /**
17 | * The font interface
18 | */
19 | interface FontInterface
20 | {
21 | /**
22 | * Gets the fontfile for current font
23 | *
24 | * @return string
25 | */
26 | public function getFile();
27 |
28 | /**
29 | * Gets font's integer point size
30 | *
31 | * @return integer
32 | */
33 | public function getSize();
34 |
35 | /**
36 | * Gets font's color
37 | *
38 | * @return ColorInterface
39 | */
40 | public function getColor();
41 |
42 | /**
43 | * Gets BoxInterface of font size on the image based on string and angle
44 | *
45 | * @param string $string
46 | * @param integer $angle
47 | *
48 | * @return BoxInterface
49 | */
50 | public function box($string, $angle = 0);
51 | }
52 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Save.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Filter\FilterInterface;
16 |
17 | /**
18 | * A save filter
19 | */
20 | class Save implements FilterInterface
21 | {
22 | /**
23 | * @var string
24 | */
25 | private $path;
26 |
27 | /**
28 | * @var array
29 | */
30 | private $options;
31 |
32 | /**
33 | * Constructs Save filter with given path and options
34 | *
35 | * @param string $path
36 | * @param array $options
37 | */
38 | public function __construct($path = null, array $options = array())
39 | {
40 | $this->path = $path;
41 | $this->options = $options;
42 | }
43 |
44 | /**
45 | * {@inheritdoc}
46 | */
47 | public function apply(ImageInterface $image)
48 | {
49 | return $image->save($this->path, $this->options);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Show.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Filter\FilterInterface;
16 |
17 | /**
18 | * A show filter
19 | */
20 | class Show implements FilterInterface
21 | {
22 | /**
23 | * @var string
24 | */
25 | private $format;
26 |
27 | /**
28 | * @var array
29 | */
30 | private $options;
31 |
32 | /**
33 | * Constructs the Show filter with given format and options
34 | *
35 | * @param string $format
36 | * @param array $options
37 | */
38 | public function __construct($format, array $options = array())
39 | {
40 | $this->format = $format;
41 | $this->options = $options;
42 | }
43 |
44 | /**
45 | * {@inheritdoc}
46 | */
47 | public function apply(ImageInterface $image)
48 | {
49 | return $image->show($this->format, $this->options);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Resize.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Filter\FilterInterface;
15 | use Imagine\Image\ImageInterface;
16 | use Imagine\Image\BoxInterface;
17 |
18 | /**
19 | * A resize filter
20 | */
21 | class Resize implements FilterInterface
22 | {
23 | /**
24 | * @var BoxInterface
25 | */
26 | private $size;
27 | private $filter;
28 |
29 | /**
30 | * Constructs Resize filter with given width and height
31 | *
32 | * @param BoxInterface $size
33 | * @param string $filter
34 | */
35 | public function __construct(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED)
36 | {
37 | $this->size = $size;
38 | $this->filter = $filter;
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function apply(ImageInterface $image)
45 | {
46 | return $image->resize($this->size, $this->filter);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/AbstractImagine.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Image\Metadata\DefaultMetadataReader;
15 | use Imagine\Image\Metadata\MetadataReaderInterface;
16 |
17 | abstract class AbstractImagine implements ImagineInterface
18 | {
19 | /** @var MetadataReaderInterface */
20 | private $metadataReader;
21 |
22 | /**
23 | * @param MetadataReaderInterface $metadataReader
24 | *
25 | * @return ImagineInterface
26 | */
27 | public function setMetadataReader(MetadataReaderInterface $metadataReader)
28 | {
29 | $this->metadataReader = $metadataReader;
30 |
31 | return $this;
32 | }
33 |
34 | /**
35 | * @return MetadataReaderInterface
36 | */
37 | public function getMetadataReader()
38 | {
39 | if (null === $this->metadataReader) {
40 | $this->metadataReader = new DefaultMetadataReader();
41 | }
42 |
43 | return $this->metadataReader;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gd/Font.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gd;
13 |
14 | use Imagine\Exception\RuntimeException;
15 | use Imagine\Image\AbstractFont;
16 | use Imagine\Image\Box;
17 |
18 | /**
19 | * Font implementation using the GD library
20 | */
21 | final class Font extends AbstractFont
22 | {
23 | /**
24 | * {@inheritdoc}
25 | */
26 | public function box($string, $angle = 0)
27 | {
28 | if (!function_exists('imageftbbox')) {
29 | throw new RuntimeException('GD must have been compiled with `--with-freetype-dir` option to use the Font feature.');
30 | }
31 |
32 | $angle = -1 * $angle;
33 | $info = imageftbbox($this->size, $angle, $this->file, $string);
34 | $xs = array($info[0], $info[2], $info[4], $info[6]);
35 | $ys = array($info[1], $info[3], $info[5], $info[7]);
36 | $width = abs(max($xs) - min($xs));
37 | $height = abs(max($ys) - min($ys));
38 |
39 | return new Box($width, $height);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/AbstractLayers.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | abstract class AbstractLayers implements LayersInterface
15 | {
16 | /**
17 | * {@inheritdoc}
18 | */
19 | public function add(ImageInterface $image)
20 | {
21 | $this[] = $image;
22 |
23 | return $this;
24 | }
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | public function set($offset, ImageInterface $image)
30 | {
31 | $this[$offset] = $image;
32 |
33 | return $this;
34 | }
35 |
36 | /**
37 | * {@inheritdoc}
38 | */
39 | public function remove($offset)
40 | {
41 | unset($this[$offset]);
42 |
43 | return $this;
44 | }
45 |
46 | /**
47 | * {@inheritdoc}
48 | */
49 | public function get($offset)
50 | {
51 | return $this[$offset];
52 | }
53 |
54 | /**
55 | * {@inheritdoc}
56 | */
57 | public function has($offset)
58 | {
59 | return isset($this[$offset]);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Rotate.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 | use Imagine\Filter\FilterInterface;
17 |
18 | /**
19 | * A rotate filter
20 | */
21 | class Rotate implements FilterInterface
22 | {
23 | /**
24 | * @var integer
25 | */
26 | private $angle;
27 |
28 | /**
29 | * @var ColorInterface
30 | */
31 | private $background;
32 |
33 | /**
34 | * Constructs Rotate filter with given angle and background color
35 | *
36 | * @param integer $angle
37 | * @param ColorInterface $background
38 | */
39 | public function __construct($angle, ColorInterface $background = null)
40 | {
41 | $this->angle = $angle;
42 | $this->background = $background;
43 | }
44 |
45 | /**
46 | * {@inheritdoc}
47 | */
48 | public function apply(ImageInterface $image)
49 | {
50 | return $image->rotate($this->angle, $this->background);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Metadata/MetadataReaderInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Metadata;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | interface MetadataReaderInterface
17 | {
18 | /**
19 | * Reads metadata from a file.
20 | *
21 | * @param $file The path to the file where to read metadata.
22 | *
23 | * @throws InvalidArgumentException In case the file does not exist.
24 | *
25 | * @return MetadataBag
26 | */
27 | public function readFile($file);
28 |
29 | /**
30 | * Reads metadata from a binary string.
31 | *
32 | * @param $data The binary string to read.
33 | *
34 | * @return MetadataBag
35 | */
36 | public function readData($data);
37 |
38 | /**
39 | * Reads metadata from a stream.
40 | *
41 | * @param $resource The stream to read.
42 | *
43 | * @throws InvalidArgumentException In case the resource is not valid.
44 | *
45 | * @return MetadataBag
46 | */
47 | public function readStream($resource);
48 | }
49 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/PointInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | /**
15 | * The point interface
16 | */
17 | interface PointInterface
18 | {
19 | /**
20 | * Gets points x coordinate
21 | *
22 | * @return integer
23 | */
24 | public function getX();
25 |
26 | /**
27 | * Gets points y coordinate
28 | *
29 | * @return integer
30 | */
31 | public function getY();
32 |
33 | /**
34 | * Checks if current coordinate is inside a given bo
35 | *
36 | * @param BoxInterface $box
37 | *
38 | * @return Boolean
39 | */
40 | public function in(BoxInterface $box);
41 |
42 | /**
43 | * Returns another point, moved by a given amount from current coordinates
44 | *
45 | * @param integer $amount
46 | * @return ImageInterface
47 | */
48 | public function move($amount);
49 |
50 | /**
51 | * Gets a string representation for the current point
52 | *
53 | * @return string
54 | */
55 | public function __toString();
56 | }
57 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Paste.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Image\PointInterface;
16 | use Imagine\Filter\FilterInterface;
17 |
18 | /**
19 | * A paste filter
20 | */
21 | class Paste implements FilterInterface
22 | {
23 | /**
24 | * @var ImageInterface
25 | */
26 | private $image;
27 |
28 | /**
29 | * @var PointInterface
30 | */
31 | private $start;
32 |
33 | /**
34 | * Constructs a Paste filter with given ImageInterface to paste and x, y
35 | * coordinates of target position
36 | *
37 | * @param ImageInterface $image
38 | * @param PointInterface $start
39 | */
40 | public function __construct(ImageInterface $image, PointInterface $start)
41 | {
42 | $this->image = $image;
43 | $this->start = $start;
44 | }
45 |
46 | /**
47 | * {@inheritdoc}
48 | */
49 | public function apply(ImageInterface $image)
50 | {
51 | return $image->paste($this->image, $this->start);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Crop.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Image\BoxInterface;
16 | use Imagine\Image\PointInterface;
17 | use Imagine\Filter\FilterInterface;
18 |
19 | /**
20 | * A crop filter
21 | */
22 | class Crop implements FilterInterface
23 | {
24 | /**
25 | * @var PointInterface
26 | */
27 | private $start;
28 |
29 | /**
30 | * @var BoxInterface
31 | */
32 | private $size;
33 |
34 | /**
35 | * Constructs a Crop filter with given x, y, coordinates and crop width and
36 | * height values
37 | *
38 | * @param PointInterface $start
39 | * @param BoxInterface $size
40 | */
41 | public function __construct(PointInterface $start, BoxInterface $size)
42 | {
43 | $this->start = $start;
44 | $this->size = $size;
45 | }
46 |
47 | /**
48 | * {@inheritdoc}
49 | */
50 | public function apply(ImageInterface $image)
51 | {
52 | return $image->crop($this->start, $this->size);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2004-2012 Bulat Shakirzyanov
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is furnished
8 | to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
21 | This software embeds Adobe ICC Profiles, see license at
22 | http://www.adobe.com/support/downloads/iccprofiles/icc_eula_mac_dist.html .
23 |
24 | This sofwtare also embeds ICC Profile from colormanagement.org. Please
25 | find information about their license at http://colormanagement.org/ .
26 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/ImagineAware.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 | use Imagine\Image\ImagineInterface;
16 |
17 | /**
18 | * ImagineAware base class
19 | */
20 | abstract class ImagineAware implements FilterInterface
21 | {
22 | /**
23 | * An ImagineInterface instance.
24 | *
25 | * @var ImagineInterface
26 | */
27 | private $imagine;
28 |
29 | /**
30 | * Set ImagineInterface instance.
31 | *
32 | * @param ImagineInterface $imagine An ImagineInterface instance
33 | */
34 | public function setImagine(ImagineInterface $imagine)
35 | {
36 | $this->imagine = $imagine;
37 | }
38 |
39 | /**
40 | * Get ImagineInterface instance.
41 | *
42 | * @return ImagineInterface
43 | *
44 | * @throws InvalidArgumentException
45 | */
46 | public function getImagine()
47 | {
48 | if (!$this->imagine instanceof ImagineInterface) {
49 | throw new InvalidArgumentException(sprintf('In order to use %s pass an Imagine\Image\ImagineInterface instance to filter constructor', get_class($this)));
50 | }
51 |
52 | return $this->imagine;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Thumbnail.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Image\ImageInterface;
15 | use Imagine\Image\BoxInterface;
16 | use Imagine\Filter\FilterInterface;
17 |
18 | /**
19 | * A thumbnail filter
20 | */
21 | class Thumbnail implements FilterInterface
22 | {
23 | /**
24 | * @var BoxInterface
25 | */
26 | private $size;
27 |
28 | /**
29 | * @var string
30 | */
31 | private $mode;
32 |
33 | /**
34 | * @var string
35 | */
36 | private $filter;
37 |
38 | /**
39 | * Constructs the Thumbnail filter with given width, height and mode
40 | *
41 | * @param BoxInterface $size
42 | * @param string $mode
43 | * @param string $filter
44 | */
45 | public function __construct(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
46 | {
47 | $this->size = $size;
48 | $this->mode = $mode;
49 | $this->filter = $filter;
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function apply(ImageInterface $image)
56 | {
57 | return $image->thumbnail($this->size, $this->mode, $this->filter);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/core/components/resizer/lexicon/en/default.inc.php:
--------------------------------------------------------------------------------
1 | 2: Auto / Imagick
1: Gmagick
0: GD
On Auto, Resizer will select the best available library. Use another value to limit its search. Check phpinfo() on your system to find out what you’ve got.
Default: 2';
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Profile.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | class Profile implements ProfileInterface
17 | {
18 | private $data;
19 | private $name;
20 |
21 | public function __construct($name, $data)
22 | {
23 | $this->name = $name;
24 | $this->data = $data;
25 | }
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | public function name()
31 | {
32 | return $this->name;
33 | }
34 |
35 | /**
36 | * {@inheritdoc}
37 | */
38 | public function data()
39 | {
40 | return $this->data;
41 | }
42 |
43 | /**
44 | * Creates a profile from a path to a file
45 | *
46 | * @param String $path
47 | *
48 | * @return Profile
49 | *
50 | * @throws InvalidArgumentException In case the provided path is not valid
51 | */
52 | public static function fromPath($path)
53 | {
54 | if (!file_exists($path) || !is_file($path) || !is_readable($path)) {
55 | throw new InvalidArgumentException(sprintf('Path %s is an invalid profile file or is not readable', $path));
56 | }
57 |
58 | return new static(basename($path), file_get_contents($path));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | $path) {
31 | $loader->set($namespace, $path);
32 | }
33 |
34 | // $map = require __DIR__ . '/autoload_psr4.php';
35 | // foreach ($map as $namespace => $path) {
36 | // $loader->setPsr4($namespace, $path);
37 | // }
38 |
39 | $classMap = require __DIR__ . '/autoload_classmap.php';
40 | if ($classMap) {
41 | $loader->addClassMap($classMap);
42 | }
43 |
44 | $loader->register(true);
45 |
46 | return $loader;
47 | }
48 | }
49 |
50 | function composerRequired444980d5d695fbdc58047d643c98ecd($file)
51 | {
52 | require $file;
53 | }
54 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/AbstractFont.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Image\Palette\Color\ColorInterface;
15 |
16 | /**
17 | * Abstract font base class
18 | */
19 | abstract class AbstractFont implements FontInterface
20 | {
21 | /**
22 | * @var string
23 | */
24 | protected $file;
25 |
26 | /**
27 | * @var integer
28 | */
29 | protected $size;
30 |
31 | /**
32 | * @var ColorInterface
33 | */
34 | protected $color;
35 |
36 | /**
37 | * Constructs a font with specified $file, $size and $color
38 | *
39 | * The font size is to be specified in points (e.g. 10pt means 10)
40 | *
41 | * @param string $file
42 | * @param integer $size
43 | * @param ColorInterface $color
44 | */
45 | public function __construct($file, $size, ColorInterface $color)
46 | {
47 | $this->file = $file;
48 | $this->size = $size;
49 | $this->color = $color;
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | final public function getFile()
56 | {
57 | return $this->file;
58 | }
59 |
60 | /**
61 | * {@inheritdoc}
62 | */
63 | final public function getSize()
64 | {
65 | return $this->size;
66 | }
67 |
68 | /**
69 | * {@inheritdoc}
70 | */
71 | final public function getColor()
72 | {
73 | return $this->color;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Metadata/MetadataBag.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Metadata;
13 |
14 | /**
15 | * An interface for Image Metadata
16 | */
17 | class MetadataBag implements \ArrayAccess, \IteratorAggregate
18 | {
19 | /** @var array */
20 | private $data;
21 |
22 | public function __construct(array $data = array())
23 | {
24 | $this->data = $data;
25 | }
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | public function getIterator()
31 | {
32 | return new \ArrayIterator($this->data);
33 | }
34 |
35 | /**
36 | * {@inheritdoc}
37 | */
38 | public function offsetExists($offset)
39 | {
40 | return array_key_exists($offset, $this->data);
41 | }
42 |
43 | /**
44 | * {@inheritdoc}
45 | */
46 | public function offsetSet($offset, $value)
47 | {
48 | $this->data[$offset] = $value;
49 | }
50 |
51 | /**
52 | * {@inheritdoc}
53 | */
54 | public function offsetUnset($offset)
55 | {
56 | unset($this->data[$offset]);
57 | }
58 |
59 | /**
60 | * {@inheritdoc}
61 | */
62 | public function offsetGet($offset)
63 | {
64 | return array_key_exists($offset, $this->data) ? $this->data[$offset] : null;
65 | }
66 |
67 | /**
68 | * Returns metadata as an array
69 | *
70 | * @return array An associative array
71 | */
72 | public function toArray()
73 | {
74 | return $this->data;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/core/components/resizer/model/resizer.class.php:
--------------------------------------------------------------------------------
1 | getOption('resizer.graphics_library', null, 2);
33 | }
34 | parent::__construct($graphicsLib);
35 | $this->debugmessages = str_replace('Reductionist', 'Resizer', $this->debugmessages);
36 | // Add some common MODX search paths for watermark images and fonts
37 | self::$assetpaths[] = $modx->getOption('assets_path');
38 | self::$assetpaths[] = $modx->getOption('base_path');
39 | self::$assetpaths[] = MODX_CORE_PATH;
40 | self::$assetpaths[] = MODX_CORE_PATH . 'model/phpthumb/fonts/';
41 | self::$assetpaths[] = MODX_CORE_PATH . 'model/phpthumb/images/';
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gmagick/Font.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gmagick;
13 |
14 | use Imagine\Image\AbstractFont;
15 | use Imagine\Image\Box;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 |
18 | /**
19 | * Font implementation using the Gmagick PHP extension
20 | */
21 | final class Font extends AbstractFont
22 | {
23 | /**
24 | * @var \Gmagick
25 | */
26 | private $gmagick;
27 |
28 | /**
29 | * @param \Gmagick $gmagick
30 | * @param string $file
31 | * @param integer $size
32 | * @param ColorInterface $color
33 | */
34 | public function __construct(\Gmagick $gmagick, $file, $size, ColorInterface $color)
35 | {
36 | $this->gmagick = $gmagick;
37 |
38 | parent::__construct($file, $size, $color);
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function box($string, $angle = 0)
45 | {
46 | $text = new \GmagickDraw();
47 |
48 | $text->setfont($this->file);
49 | /**
50 | * @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
51 | *
52 | * ensure font resolution is the same as GD's hard-coded 96
53 | */
54 | $text->setfontsize((int) ($this->size * (96 / 72)));
55 | $text->setfontstyle(\Gmagick::STYLE_OBLIQUE);
56 |
57 | $info = $this->gmagick->queryfontmetrics($text, $string);
58 |
59 | $box = new Box($info['textWidth'], $info['textHeight']);
60 |
61 | return $box;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Point/Center.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Point;
13 |
14 | use Imagine\Image\BoxInterface;
15 | use Imagine\Image\Point as OriginalPoint;
16 | use Imagine\Image\PointInterface;
17 |
18 | /**
19 | * Point center
20 | */
21 | final class Center implements PointInterface
22 | {
23 | /**
24 | * @var BoxInterface
25 | */
26 | private $box;
27 |
28 | /**
29 | * Constructs coordinate with size instance, it needs to be relative to
30 | *
31 | * @param BoxInterface $box
32 | */
33 | public function __construct(BoxInterface $box)
34 | {
35 | $this->box = $box;
36 | }
37 |
38 | /**
39 | * {@inheritdoc}
40 | */
41 | public function getX()
42 | {
43 | return ceil($this->box->getWidth() / 2);
44 | }
45 |
46 | /**
47 | * {@inheritdoc}
48 | */
49 | public function getY()
50 | {
51 | return ceil($this->box->getHeight() / 2);
52 | }
53 |
54 | /**
55 | * {@inheritdoc}
56 | */
57 | public function in(BoxInterface $box)
58 | {
59 | return $this->getX() < $box->getWidth() && $this->getY() < $box->getHeight();
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | public function move($amount)
66 | {
67 | return new OriginalPoint($this->getX() + $amount, $this->getY() + $amount);
68 | }
69 |
70 | /**
71 | * {@inheritdoc}
72 | */
73 | public function __toString()
74 | {
75 | return sprintf('(%d, %d)', $this->getX(), $this->getY());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Effects/EffectsInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Effects;
13 |
14 | use Imagine\Exception\RuntimeException;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 |
17 | /**
18 | * Interface for the effects
19 | */
20 | interface EffectsInterface
21 | {
22 | /**
23 | * Apply gamma correction
24 | *
25 | * @param float $correction
26 | * @return EffectsInterface
27 | *
28 | * @throws RuntimeException
29 | */
30 | public function gamma($correction);
31 |
32 | /**
33 | * Invert the colors of the image
34 | *
35 | * @return EffectsInterface
36 | *
37 | * @throws RuntimeException
38 | */
39 | public function negative();
40 |
41 | /**
42 | * Grayscale the image
43 | *
44 | * @return EffectsInterface
45 | *
46 | * @throws RuntimeException
47 | */
48 | public function grayscale();
49 |
50 | /**
51 | * Colorize the image
52 | *
53 | * @param ColorInterface $color
54 | *
55 | * @return EffectsInterface
56 | *
57 | * @throws RuntimeException
58 | */
59 | public function colorize(ColorInterface $color);
60 |
61 | /**
62 | * Sharpens the image
63 | *
64 | * @return EffectsInterface
65 | *
66 | * @throws RuntimeException
67 | */
68 | public function sharpen();
69 |
70 | /**
71 | * Blur the image
72 | *
73 | * @param float|int $sigma
74 | *
75 | * @return EffectsInterface
76 | *
77 | * @throws RuntimeException
78 | */
79 | public function blur($sigma);
80 | }
81 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Imagick/Font.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Imagick;
13 |
14 | use Imagine\Image\AbstractFont;
15 | use Imagine\Image\Box;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 |
18 | /**
19 | * Font implementation using the Imagick PHP extension
20 | */
21 | final class Font extends AbstractFont
22 | {
23 | /**
24 | * @var \Imagick
25 | */
26 | private $imagick;
27 |
28 | /**
29 | * @param \Imagick $imagick
30 | * @param string $file
31 | * @param integer $size
32 | * @param ColorInterface $color
33 | */
34 | public function __construct(\Imagick $imagick, $file, $size, ColorInterface $color)
35 | {
36 | $this->imagick = $imagick;
37 |
38 | parent::__construct($file, $size, $color);
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function box($string, $angle = 0)
45 | {
46 | $text = new \ImagickDraw();
47 |
48 | $text->setFont($this->file);
49 |
50 | /**
51 | * @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
52 | *
53 | * ensure font resolution is the same as GD's hard-coded 96
54 | */
55 | if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
56 | $text->setResolution(96, 96);
57 | $text->setFontSize($this->size);
58 | } else {
59 | $text->setFontSize((int) ($this->size * (96 / 72)));
60 | }
61 |
62 | $info = $this->imagick->queryFontMetrics($text, $string);
63 |
64 | $box = new Box($info['textWidth'], $info['textHeight']);
65 |
66 | return $box;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Point.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | /**
17 | * The point class
18 | */
19 | final class Point implements PointInterface
20 | {
21 | /**
22 | * @var integer
23 | */
24 | private $x;
25 |
26 | /**
27 | * @var integer
28 | */
29 | private $y;
30 |
31 | /**
32 | * Constructs a point of coordinates
33 | *
34 | * @param integer $x
35 | * @param integer $y
36 | *
37 | * @throws InvalidArgumentException
38 | */
39 | public function __construct($x, $y)
40 | {
41 | if ($x < 0 || $y < 0) {
42 | throw new InvalidArgumentException('A coordinate cannot be positioned outside of a bounding box');
43 | }
44 |
45 | $this->x = $x;
46 | $this->y = $y;
47 | }
48 |
49 | /**
50 | * {@inheritdoc}
51 | */
52 | public function getX()
53 | {
54 | return $this->x;
55 | }
56 |
57 | /**
58 | * {@inheritdoc}
59 | */
60 | public function getY()
61 | {
62 | return $this->y;
63 | }
64 |
65 | /**
66 | * {@inheritdoc}
67 | */
68 | public function in(BoxInterface $box)
69 | {
70 | return $this->x < $box->getWidth() && $this->y < $box->getHeight();
71 | }
72 |
73 | /**
74 | * {@inheritdoc}
75 | */
76 | public function move($amount)
77 | {
78 | return new Point($this->x + $amount, $this->y + $amount);
79 | }
80 |
81 | /**
82 | * {@inheritdoc}
83 | */
84 | public function __toString()
85 | {
86 | return sprintf('(%d, %d)', $this->x, $this->y);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Basic/Autorotate.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter\Basic;
13 |
14 | use Imagine\Filter\FilterInterface;
15 | use Imagine\Image\ImageInterface;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 |
18 | /**
19 | * Rotates an image automatically based on exif information.
20 | *
21 | * Your attention please: This filter requires the use of the
22 | * ExifMetadataReader to work.
23 | *
24 | * @see https://imagine.readthedocs.org/en/latest/usage/metadata.html
25 | */
26 | class Autorotate implements FilterInterface
27 | {
28 | private $color;
29 |
30 | /**
31 | * @param string|array|ColorInterface $color A color
32 | */
33 | public function __construct($color = '000000')
34 | {
35 | $this->color = $color;
36 | }
37 |
38 | /**
39 | * {@inheritdoc}
40 | */
41 | public function apply(ImageInterface $image)
42 | {
43 | $metadata = $image->metadata();
44 |
45 | switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
46 | case 3:
47 | $image->rotate(180, $this->getColor($image));
48 | break;
49 | case 6:
50 | $image->rotate(90, $this->getColor($image));
51 | break;
52 | case 8:
53 | $image->rotate(-90, $this->getColor($image));
54 | break;
55 | default:
56 | break;
57 | }
58 |
59 | return $image;
60 | }
61 |
62 | private function getColor(ImageInterface $image)
63 | {
64 | if ($this->color instanceof ColorInterface) {
65 | return $this->color;
66 | }
67 |
68 | return $image->palette()->color($this->color);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/README.md:
--------------------------------------------------------------------------------
1 | #Imagine
2 | [](http://stillmaintained.com/avalanche123/Imagine)
3 | [](http://travis-ci.org/avalanche123/Imagine)
4 |
5 | Tweet about it using the [#php_imagine](https://twitter.com/search?q=%23php_imagine) hashtag.
6 |
7 | Image manipulation library for PHP 5.3 inspired by Python's PIL and other image
8 | libraries.
9 |
10 | ##Requirements##
11 |
12 | The Imagine library has the following requirements:
13 |
14 | - PHP 5.3+
15 |
16 | Depending on the chosen Image implementation, you may need one of the following:
17 |
18 | - GD2
19 | - Imagick
20 | - Gmagick
21 |
22 | ##Basic Principles##
23 |
24 | The main purpose of Imagine is to provide all the necessary functionality to bring all native low level image processing libraries in PHP to the same simple and intuitive OO API.
25 |
26 | Several things are necessary to accomplish that:
27 |
28 | * Image manipulation tools, such as resize, crop, etc.
29 | * Drawing API - to create basic shapes and advanced charts, write text on the image
30 | * Masking functionality - ability to apply black&white or grayscale images as masks, leading to semi-transparency or absolute transparency of the image the mask is being applied to
31 |
32 | The above tools should be the basic foundation for a more powerful set of tools that are called ``Filters`` in Imagine.
33 |
34 | Some of the ideas for upcoming filters:
35 |
36 | * Charting and graphing filters - pie and bar charts, linear graphs with annotations
37 | * Reflection - apple style
38 | * Rounded corners - web 2.0
39 |
40 | ## Documentation ##
41 |
42 | - [Hosted by Read The Docs](http://imagine.readthedocs.org/)
43 |
44 | ## Presentations ##
45 |
46 | - [Introduction to Imagine](http://www.slideshare.net/avalanche123/introduction-toimagine)
47 | - [How to Take Over the World with Lithium](http://speakerdeck.com/u/nateabele/p/how-to-take-over-the-world-with-lithium?slide=33)
48 |
49 | ## Articles ##
50 |
51 | - [Image Processing with Imagine](http://www.phparch.com/2011/03/image-processing-with-imagine)
52 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/ImagineInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Image\Palette\Color\ColorInterface;
15 | use Imagine\Exception\InvalidArgumentException;
16 | use Imagine\Exception\RuntimeException;
17 |
18 | /**
19 | * The imagine interface
20 | */
21 | interface ImagineInterface
22 | {
23 | const VERSION = '0.3.0';
24 |
25 | /**
26 | * Creates a new empty image with an optional background color
27 | *
28 | * @param BoxInterface $size
29 | * @param ColorInterface $color
30 | *
31 | * @throws InvalidArgumentException
32 | * @throws RuntimeException
33 | *
34 | * @return ImageInterface
35 | */
36 | public function create(BoxInterface $size, ColorInterface $color = null);
37 |
38 | /**
39 | * Opens an existing image from $path
40 | *
41 | * @param string $path
42 | *
43 | * @throws RuntimeException
44 | *
45 | * @return ImageInterface
46 | */
47 | public function open($path);
48 |
49 | /**
50 | * Loads an image from a binary $string
51 | *
52 | * @param string $string
53 | *
54 | * @throws RuntimeException
55 | *
56 | * @return ImageInterface
57 | * @return ImageInterface
58 | */
59 | public function load($string);
60 |
61 | /**
62 | * Loads an image from a resource $resource
63 | *
64 | * @param resource $resource
65 | *
66 | * @throws RuntimeException
67 | *
68 | * @return ImageInterface
69 | */
70 | public function read($resource);
71 |
72 | /**
73 | * Constructs a font with specified $file, $size and $color
74 | *
75 | * The font size is to be specified in points (e.g. 10pt means 10)
76 | *
77 | * @param string $file
78 | * @param integer $size
79 | * @param ColorInterface $color
80 | *
81 | * @return FontInterface
82 | */
83 | public function font($file, $size, ColorInterface $color);
84 | }
85 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/BoxInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | /**
15 | * Interface for a box
16 | */
17 | interface BoxInterface
18 | {
19 | /**
20 | * Gets current image height
21 | *
22 | * @return integer
23 | */
24 | public function getHeight();
25 |
26 | /**
27 | * Gets current image width
28 | *
29 | * @return integer
30 | */
31 | public function getWidth();
32 |
33 | /**
34 | * Creates new BoxInterface instance with ratios applied to both sides
35 | *
36 | * @param float $ratio
37 | *
38 | * @return BoxInterface
39 | */
40 | public function scale($ratio);
41 |
42 | /**
43 | * Creates new BoxInterface, adding given size to both sides
44 | *
45 | * @param integer $size
46 | *
47 | * @return BoxInterface
48 | */
49 | public function increase($size);
50 |
51 | /**
52 | * Checks whether current box can fit given box at a given start position,
53 | * start position defaults to top left corner xy(0,0)
54 | *
55 | * @param BoxInterface $box
56 | * @param PointInterface $start
57 | *
58 | * @return Boolean
59 | */
60 | public function contains(BoxInterface $box, PointInterface $start = null);
61 |
62 | /**
63 | * Gets current box square, useful for getting total number of pixels in a
64 | * given box
65 | *
66 | * @return integer
67 | */
68 | public function square();
69 |
70 | /**
71 | * Returns a string representation of the current box
72 | *
73 | * @return string
74 | */
75 | public function __toString();
76 |
77 | /**
78 | * Resizes box to given width, constraining proportions and returns the new box
79 | *
80 | * @param integer $width
81 | *
82 | * @return BoxInterface
83 | */
84 | public function widen($width);
85 |
86 | /**
87 | * Resizes box to given height, constraining proportions and returns the new box
88 | *
89 | * @param integer $height
90 | *
91 | * @return BoxInterface
92 | */
93 | public function heighten($height);
94 | }
95 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/Color/ColorInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette\Color;
13 |
14 | use Imagine\Image\Palette\PaletteInterface;
15 |
16 | interface ColorInterface
17 | {
18 | const COLOR_RED = 'red';
19 | const COLOR_GREEN = 'green';
20 | const COLOR_BLUE = 'blue';
21 |
22 | const COLOR_CYAN = 'cyan';
23 | const COLOR_MAGENTA = 'magenta';
24 | const COLOR_YELLOW = 'yellow';
25 | const COLOR_KEYLINE = 'keyline';
26 |
27 | const COLOR_GRAY = 'gray';
28 |
29 | /**
30 | * Return the value of one of the component.
31 | *
32 | * @param string $component One of the ColorInterface::COLOR_* component
33 | *
34 | * @return Integer
35 | */
36 | public function getValue($component);
37 |
38 | /**
39 | * Returns percentage of transparency of the color
40 | *
41 | * @return integer
42 | */
43 | public function getAlpha();
44 |
45 | /**
46 | * Returns the palette attached to the current color
47 | *
48 | * @return PaletteInterface
49 | */
50 | public function getPalette();
51 |
52 | /**
53 | * Returns a copy of current color, incrementing the alpha channel by the
54 | * given amount
55 | *
56 | * @param integer $alpha
57 | *
58 | * @return ColorInterface
59 | */
60 | public function dissolve($alpha);
61 |
62 | /**
63 | * Returns a copy of the current color, lightened by the specified number
64 | * of shades
65 | *
66 | * @param integer $shade
67 | *
68 | * @return ColorInterface
69 | */
70 | public function lighten($shade);
71 |
72 | /**
73 | * Returns a copy of the current color, darkened by the specified number of
74 | * shades
75 | *
76 | * @param integer $shade
77 | *
78 | * @return ColorInterface
79 | */
80 | public function darken($shade);
81 |
82 | /**
83 | * Returns a gray related to the current color
84 | *
85 | * @return ColorInterface
86 | */
87 | public function grayscale();
88 |
89 | /**
90 | * Checks if the current color is opaque
91 | *
92 | * @return Boolean
93 | */
94 | public function isOpaque();
95 | }
96 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/PaletteInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette;
13 |
14 | use Imagine\Image\ProfileInterface;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 |
17 | interface PaletteInterface
18 | {
19 | const PALETTE_GRAYSCALE = 'gray';
20 | const PALETTE_RGB = 'rgb';
21 | const PALETTE_CMYK = 'cmyk';
22 |
23 | /**
24 | * Returns a color given some values
25 | *
26 | * @param string|array|integer $color A color
27 | * @param integer|null $alpha Set alpha to null to disable it
28 | *
29 | * @return ColorInterface
30 | *
31 | * @throws InvalidArgumentException In case you pass an alpha value to a
32 | * Palette that does not support alpha
33 | */
34 | public function color($color, $alpha = null);
35 |
36 | /**
37 | * Blend two colors given an amount
38 | *
39 | * @param ColorInterface $color1
40 | * @param ColorInterface $color2
41 | * @param float $amount The amount of color2 in color1
42 | *
43 | * @return ColorInterface
44 | */
45 | public function blend(ColorInterface $color1, ColorInterface $color2, $amount);
46 |
47 | /**
48 | * Attachs an ICC profile to this Palette.
49 | *
50 | * (A default profile is provided by default)
51 | *
52 | * @param ProfileInterface $profile
53 | *
54 | * @return PaletteInterface
55 | */
56 | public function useProfile(ProfileInterface $profile);
57 |
58 | /**
59 | * Returns the ICC profile attached to this Palette.
60 | *
61 | * @return ProfileInterface
62 | */
63 | public function profile();
64 |
65 | /**
66 | * Returns the name of this Palette, one of PaletteInterface::PALETTE_*
67 | * constants
68 | *
69 | * @return String
70 | */
71 | public function name();
72 |
73 | /**
74 | * Returns an array containing ColorInterface::COLOR_* constants that
75 | * define the structure of colors for a pixel.
76 | *
77 | * @return array
78 | */
79 | public function pixelDefinition();
80 |
81 | /**
82 | * Tells if alpha channel is supported in this palette
83 | *
84 | * @return Boolean
85 | */
86 | public function supportsAlpha();
87 | }
88 |
--------------------------------------------------------------------------------
/core/components/resizer/docs/changelog.txt:
--------------------------------------------------------------------------------
1 | Resizer Changelog
2 |
3 | v1.0.1-pl [26.05.2014]
4 | -----------------------
5 |
6 | - [#6] GD: Fix PNG transparency on watermark images
7 | - Add MODX base_path to search list for watermark assets
8 |
9 |
10 | v1.0.0-pl [29.04.2014]
11 | -----------------------
12 |
13 | - Structural overhaul: core functionality now bundled as a Composer
14 | package (oo12/Reductionist)
15 | - Performance improvements for thumbnailing large jpegs using Imagick
16 | or Gmagick
17 | - Add preliminary support for watermarking: wmt and wmi filters
18 | (hat tip funkbilly)
19 | - Add auto CMYK to RGB conversion and strip embedded profiles/metadata
20 | to reduce thumbnail size
21 | - Improve handling of rounding discrepancies when calculating dimensions
22 | - Fix quality scaling when zoom cropping
23 |
24 |
25 | v0.5.1-pl [23.03.2014]
26 | -----------------------
27 |
28 | - Fix handing of far parameter for undersized images when aoe=0
29 | - Fix reported output dimensions in some cases
30 |
31 |
32 | v0.5.0-pl [15.03.2014]
33 | -----------------------
34 |
35 | - [#3] Add partial support for fltr[]=usm
36 | - [#4] Fix execution order for source crop parameters. Now works with
37 | Image+ 2.2.
38 | - Improve debug output
39 | - Add properties for final width and height
40 | - Merge latest Imagine commits
41 | - Several minor performance tweaks
42 |
43 |
44 | v0.4.1-pl [10.11.2013]
45 | -----------------------
46 |
47 | - Make input file checking and class loading a little more robust
48 |
49 |
50 | v0.4.0-pl [05.10.2013]
51 | -----------------------
52 |
53 | - Add bg (background color) parameter
54 | - Add far (force aspect ratio) parameter
55 | - [#1] Fix an issue with the package validator and older versions of
56 | the Imagick extension
57 | - Merge latest Imagine commits
58 |
59 |
60 | v0.3.2-pl [29.09.2013]
61 | -----------------------
62 |
63 | - Fix a bug in the Imagine Imagick driver (affected a few, mostly older
64 | versions of ImageMagick)
65 |
66 |
67 | v0.3.1-pl [08.09.2013]
68 | -----------------------
69 |
70 | - Fix a bug when sw or sh (but not both) is specified
71 |
72 |
73 | v0.3.0-pl [07.09.2013]
74 | -----------------------
75 |
76 | - Add sw, sh, sx, sy options
77 | - Add maxq option for jpeg quality scaling on undersized input images
78 | - Add available memory check when using GD
79 | - Fix scale option name and improve operation
80 | - Expand debug messages
81 | - Merge latest Imagine commits
82 |
83 |
84 | v0.2.0-rc1 [25.08.2013]
85 | --------------------
86 |
87 | - Convert to a separate package
88 | - Add scale and strip options
89 | - Integrate latest Imagine repo
90 | - Improve error handling
91 | - Add more debug info
92 | - Various minor improvements
93 |
94 |
95 | v0.1.0
96 | ------
97 |
98 | - Initial Release
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Gmagick/RImage.php:
--------------------------------------------------------------------------------
1 | image = new Image($resource, $palette, $metadata);
17 | if (is_array($size)) { $this->size = $size; }
18 | else {
19 | $size = $this->image->getSize();
20 | $this->size = array($size->getWidth(), $size->getHeight());
21 | }
22 | }
23 | }
24 |
25 |
26 | public function resize(BoxInterface $size, $filter = null) {
27 | $width = $size->getWidth();
28 | $height = $size->getHeight();
29 | if ($this->image === null) { $this->load(array($width, $height)); }
30 |
31 | $magick = $this->image->getGmagick();
32 | $magick->scaleimage($width, $height);
33 | $magick->stripimage();
34 | $this->size = array($width, $height);
35 |
36 | return $this;
37 | }
38 |
39 |
40 | public function crop(PointInterface $start, BoxInterface $size) {
41 | if ($this->image === null) { $this->load(); }
42 |
43 | $width = $size->getWidth();
44 | $height = $size->getHeight();
45 |
46 | try {
47 | $this->image->getGmagick()->cropimage($width, $height, $start->getX(), $start->getY());
48 | }
49 | catch (\GmagickException $e) {
50 | throw new \Imagine\Exception\RuntimeException("Gmagick: Crop operation failed. {$e->getMessage()}", $e->getCode(), $e);
51 | }
52 | $this->size = array($width, $height);
53 |
54 | return $this;
55 | }
56 |
57 |
58 | protected function load($size = null) {
59 | try {
60 | $magick = new \Gmagick();
61 | if ($this->format === IMG_JPG && $size !== null) {
62 | $magick->setsize($size[0], $size[1]);
63 | }
64 | $magick->readimage($this->filename);
65 | }
66 | catch (\Exception $e) {
67 | throw new \Imagine\Exception\RuntimeException("Gmagick: Unable to open image {$this->filename}. {$e->getMessage()}", $e->getCode(), $e);
68 | }
69 | if ($this->format === IMG_JPG && $size !== null) {
70 | $newWidth = $magick->getimagewidth();
71 | if ($newWidth !== $this->size[0]) {
72 | $this->size = $this->prescalesize = array($newWidth, $magick->getimageheight());
73 | }
74 | }
75 | $cs = $magick->getimagecolorspace();
76 | $this->image = new Image($magick, RImagine::createPalette($cs), $this->metadata);
77 |
78 | if ($cs === \Gmagick::COLORSPACE_CMYK) { // convert CMYK > RGB
79 | try {
80 | $this->image->usePalette(new RGB());
81 | }
82 | catch (\Exception $e) {
83 | $this->image->getGmagick()->stripimage(); // make sure all profiles are removed
84 | }
85 | }
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gmagick/Effects.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gmagick;
13 |
14 | use Imagine\Effects\EffectsInterface;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 | use Imagine\Exception\NotSupportedException;
18 |
19 | /**
20 | * Effects implementation using the Gmagick PHP extension
21 | */
22 | class Effects implements EffectsInterface
23 | {
24 | private $gmagick;
25 |
26 | public function __construct(\Gmagick $gmagick)
27 | {
28 | $this->gmagick = $gmagick;
29 | }
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function gamma($correction)
35 | {
36 | try {
37 | $this->gmagick->gammaimage($correction);
38 | } catch (\GmagickException $e) {
39 | throw new RuntimeException('Failed to apply gamma correction to the image');
40 | }
41 |
42 | return $this;
43 | }
44 |
45 | /**
46 | * {@inheritdoc}
47 | */
48 | public function negative()
49 | {
50 | if (!method_exists($this->gmagick, 'negateimage')) {
51 | throw new NotSupportedException('Gmagick version 1.1.0 RC3 is required for negative effect');
52 | }
53 |
54 | try {
55 | $this->gmagick->negateimage(false, \Gmagick::CHANNEL_ALL);
56 | } catch (\GmagickException $e) {
57 | throw new RuntimeException('Failed to negate the image');
58 | }
59 |
60 | return $this;
61 | }
62 |
63 | /**
64 | * {@inheritdoc}
65 | */
66 | public function grayscale()
67 | {
68 | try {
69 | $this->gmagick->setImageType(2);
70 | } catch (\GmagickException $e) {
71 | throw new RuntimeException('Failed to grayscale the image');
72 | }
73 |
74 | return $this;
75 | }
76 |
77 | /**
78 | * {@inheritdoc}
79 | */
80 | public function colorize(ColorInterface $color)
81 | {
82 | throw new NotSupportedException('Gmagick does not support colorize');
83 | }
84 |
85 | /**
86 | * {@inheritdoc}
87 | */
88 | public function sharpen()
89 | {
90 | throw new NotSupportedException('Gmagick does not support sharpen yet');
91 | }
92 |
93 | /**
94 | * {@inheritdoc}
95 | */
96 | public function blur($sigma = 1)
97 | {
98 | try {
99 | $this->gmagick->blurImage(0, $sigma);
100 | } catch (\GmagickException $e) {
101 | throw new RuntimeException('Failed to blur the image', $e->getCode(), $e);
102 | }
103 |
104 | return $this;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Metadata;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 | use Imagine\Exception\NotSupportedException;
16 |
17 | /**
18 | * Metadata driven by Exif information
19 | */
20 | class ExifMetadataReader extends AbstractMetadataReader
21 | {
22 | public function __construct()
23 | {
24 | if (!function_exists('exif_read_data')) {
25 | throw new NotSupportedException('PHP exif extension is required to use the ExifMetadataReader');
26 | }
27 | }
28 |
29 | /**
30 | * {@inheritdoc}
31 | */
32 | protected function extractFromFile($file)
33 | {
34 | if (false === $data = @file_get_contents($file)) {
35 | throw new InvalidArgumentException(sprintf('File %s is not readable.', $file));
36 | }
37 |
38 | return $this->doReadData($data);
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | protected function extractFromData($data)
45 | {
46 | return $this->doReadData($data);
47 | }
48 |
49 | /**
50 | * {@inheritdoc}
51 | */
52 | protected function extractFromStream($resource)
53 | {
54 | return $this->doReadData(stream_get_contents($resource));
55 | }
56 |
57 | /**
58 | * Extracts metadata from raw data, merges with existing metadata
59 | *
60 | * @param string $data
61 | *
62 | * @return MetadataBag
63 | */
64 | private function doReadData($data)
65 | {
66 | if (substr($data, 0, 2) === 'II') {
67 | $mime = 'image/tiff';
68 | } else {
69 | $mime = 'image/jpeg';
70 | }
71 |
72 | return $this->extract('data://' . $mime . ';base64,' . base64_encode($data));
73 | }
74 |
75 | /**
76 | * Performs the exif data extraction given a path or data-URI representation.
77 | *
78 | * @param string $path The path to the file or the data-URI representation.
79 | *
80 | * @return MetadataBag
81 | */
82 | private function extract($path)
83 | {
84 | if (false === $exifData = @exif_read_data($path, null, true, false)) {
85 | return array();
86 | }
87 |
88 | $metadata = array();
89 | $sources = array('EXIF' => 'exif', 'IFD0' => 'ifd0');
90 |
91 | foreach ($sources as $name => $prefix) {
92 | if (!isset($exifData[$name])) {
93 | continue;
94 | }
95 | foreach ($exifData[$name] as $prop => $value) {
96 | $metadata[$prefix.'.'.$prop] = $value;
97 | }
98 | }
99 |
100 | return $metadata;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Metadata/AbstractMetadataReader.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Metadata;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | abstract class AbstractMetadataReader implements MetadataReaderInterface
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | public function readFile($file)
22 | {
23 | if (stream_is_local($file)) {
24 | if (!is_file($file)) {
25 | throw new InvalidArgumentException(sprintf('File %s does not exist.', $file));
26 | }
27 |
28 | return new MetadataBag(array_merge(array('filepath' => realpath($file), 'uri' => $file), $this->extractFromFile($file)));
29 | }
30 |
31 | return new MetadataBag(array_merge(array('uri' => $file)), $this->extractFromFile($file));
32 | }
33 |
34 | /**
35 | * {@inheritdoc}
36 | */
37 | public function readData($data)
38 | {
39 | return new MetadataBag($this->extractFromData($data));
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | public function readStream($resource)
46 | {
47 | if (!is_resource($resource)) {
48 | throw new InvalidArgumentException('Invalid resource provided.');
49 | }
50 |
51 | return new MetadataBag(array_merge($this->getStreamMetadata($resource), $this->extractFromStream($resource)));
52 | }
53 |
54 | /**
55 | * Gets the URI from a stream resource
56 | *
57 | * @param resource $resource
58 | *
59 | * @return string|null The URI f ava
60 | */
61 | private function getStreamMetadata($resource)
62 | {
63 | $metadata = array();
64 |
65 | if (false !== $data = @stream_get_meta_data($resource)) {
66 | $metadata['uri'] = $data['uri'];
67 | if (stream_is_local($resource)) {
68 | $metadata['filepath'] = realpath($data['uri']);
69 | }
70 | }
71 |
72 | return $metadata;
73 | }
74 |
75 | /**
76 | * Extracts metadata from a file
77 | *
78 | * @param $file
79 | *
80 | * @return array An associative array of metadata
81 | */
82 | abstract protected function extractFromFile($file);
83 |
84 | /**
85 | * Extracts metadata from raw data
86 | *
87 | * @param $data
88 | *
89 | * @return array An associative array of metadata
90 | */
91 | abstract protected function extractFromData($data);
92 |
93 | /**
94 | * Extracts metadata from a stream
95 | *
96 | * @param $resource
97 | *
98 | * @return array An associative array of metadata
99 | */
100 | abstract protected function extractFromStream($resource);
101 | }
102 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Box.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | /**
17 | * A box implementation
18 | */
19 | final class Box implements BoxInterface
20 | {
21 | /**
22 | * @var integer
23 | */
24 | private $width;
25 |
26 | /**
27 | * @var integer
28 | */
29 | private $height;
30 |
31 | /**
32 | * Constructs the Size with given width and height
33 | *
34 | * @param integer $width
35 | * @param integer $height
36 | *
37 | * @throws InvalidArgumentException
38 | */
39 | public function __construct($width, $height)
40 | {
41 | if ($height < 1 || $width < 1) {
42 | throw new InvalidArgumentException(sprintf('Length of either side cannot be 0 or negative, current size is %sx%s', $width, $height));
43 | }
44 |
45 | $this->width = (int) $width;
46 | $this->height = (int) $height;
47 | }
48 |
49 | /**
50 | * {@inheritdoc}
51 | */
52 | public function getWidth()
53 | {
54 | return $this->width;
55 | }
56 |
57 | /**
58 | * {@inheritdoc}
59 | */
60 | public function getHeight()
61 | {
62 | return $this->height;
63 | }
64 |
65 | /**
66 | * {@inheritdoc}
67 | */
68 | public function scale($ratio)
69 | {
70 | return new Box(round($ratio * $this->width), round($ratio * $this->height));
71 | }
72 |
73 | /**
74 | * {@inheritdoc}
75 | */
76 | public function increase($size)
77 | {
78 | return new Box((int) $size + $this->width, (int) $size + $this->height);
79 | }
80 |
81 | /**
82 | * {@inheritdoc}
83 | */
84 | public function contains(BoxInterface $box, PointInterface $start = null)
85 | {
86 | $start = $start ? $start : new Point(0, 0);
87 |
88 | return $start->in($this) && $this->width >= $box->getWidth() + $start->getX() && $this->height >= $box->getHeight() + $start->getY();
89 | }
90 |
91 | /**
92 | * {@inheritdoc}
93 | */
94 | public function square()
95 | {
96 | return $this->width * $this->height;
97 | }
98 |
99 | /**
100 | * {@inheritdoc}
101 | */
102 | public function __toString()
103 | {
104 | return sprintf('%dx%d px', $this->width, $this->height);
105 | }
106 |
107 | /**
108 | * {@inheritdoc}
109 | */
110 | public function widen($width)
111 | {
112 | return $this->scale($width / $this->width);
113 | }
114 |
115 | /**
116 | * {@inheritdoc}
117 | */
118 | public function heighten($height)
119 | {
120 | return $this->scale($height / $this->height);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/LayersInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\RuntimeException;
15 | use Imagine\Exception\InvalidArgumentException;
16 | use Imagine\Exception\OutOfBoundsException;
17 |
18 | /**
19 | * The layers interface
20 | */
21 | interface LayersInterface extends \Iterator, \Countable, \ArrayAccess
22 | {
23 | /**
24 | * Merge layers into the original objects
25 | *
26 | * @throws RuntimeException
27 | */
28 | public function merge();
29 |
30 | /**
31 | * Animates layers
32 | *
33 | * @param string $format The output output format
34 | * @param integer $delay The delay in milliseconds between two frames
35 | * @param integer $loops The number of loops, 0 means infinite
36 | *
37 | * @return LayersInterface
38 | *
39 | * @throws InvalidArgumentException In case an invalid argument is provided
40 | * @throws RuntimeException In case the driver fails to animate
41 | */
42 | public function animate($format, $delay, $loops);
43 |
44 | /**
45 | * Coalesce layers. Each layer in the sequence is the same size as the first and composited with the next layer in
46 | * the sequence.
47 | */
48 | public function coalesce();
49 |
50 | /**
51 | * Adds an image at the end of the layers stack
52 | *
53 | * @param ImageInterface $image
54 | *
55 | * @return LayersInterface
56 | *
57 | * @throws RuntimeException
58 | */
59 | public function add(ImageInterface $image);
60 |
61 | /**
62 | * Set an image at offset
63 | *
64 | * @param integer $offset
65 | * @param ImageInterface $image
66 | *
67 | * @return LayersInterface
68 | *
69 | * @throws RuntimeException
70 | * @throws InvalidArgumentException
71 | * @throws OutOfBoundsException
72 | */
73 | public function set($offset, ImageInterface $image);
74 |
75 | /**
76 | * Removes the image at offset
77 | *
78 | * @param integer $offset
79 | *
80 | * @return LayersInterface
81 | *
82 | * @throws RuntimeException
83 | * @throws InvalidArgumentException
84 | */
85 | public function remove($offset);
86 |
87 | /**
88 | * Returns the image at offset
89 | *
90 | * @param integer $offset
91 | *
92 | * @return ImageInterface
93 | *
94 | * @throws RuntimeException
95 | * @throws InvalidArgumentException
96 | */
97 | public function get($offset);
98 |
99 | /**
100 | * Returns true if a layer at offset is preset
101 | *
102 | * @param integer $offset
103 | *
104 | * @return Boolean
105 | */
106 | public function has($offset);
107 | }
108 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Imagick/Effects.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Imagick;
13 |
14 | use Imagine\Effects\EffectsInterface;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 |
18 | /**
19 | * Effects implementation using the Imagick PHP extension
20 | */
21 | class Effects implements EffectsInterface
22 | {
23 | private $imagick;
24 |
25 | public function __construct(\Imagick $imagick)
26 | {
27 | $this->imagick = $imagick;
28 | }
29 |
30 | /**
31 | * {@inheritdoc}
32 | */
33 | public function gamma($correction)
34 | {
35 | try {
36 | $this->imagick->gammaImage($correction, \Imagick::CHANNEL_ALL);
37 | } catch (\ImagickException $e) {
38 | throw new RuntimeException('Failed to apply gamma correction to the image');
39 | }
40 |
41 | return $this;
42 | }
43 |
44 | /**
45 | * {@inheritdoc}
46 | */
47 | public function negative()
48 | {
49 | try {
50 | $this->imagick->negateImage(false, \Imagick::CHANNEL_ALL);
51 | } catch (\ImagickException $e) {
52 | throw new RuntimeException('Failed to negate the image');
53 | }
54 |
55 | return $this;
56 | }
57 |
58 | /**
59 | * {@inheritdoc}
60 | */
61 | public function grayscale()
62 | {
63 | try {
64 | $this->imagick->setImageType(\Imagick::IMGTYPE_GRAYSCALE);
65 | } catch (\ImagickException $e) {
66 | throw new RuntimeException('Failed to grayscale the image');
67 | }
68 |
69 | return $this;
70 | }
71 |
72 | /**
73 | * {@inheritdoc}
74 | */
75 | public function colorize(ColorInterface $color)
76 | {
77 | try {
78 | $this->imagick->colorizeImage((string) $color, 1);
79 | } catch (\ImagickException $e) {
80 | throw new RuntimeException('Failed to colorize the image');
81 | }
82 |
83 | return $this;
84 | }
85 |
86 | /**
87 | * {@inheritdoc}
88 | */
89 | public function sharpen()
90 | {
91 | try {
92 | $this->imagick->sharpenImage(2, 1);
93 | } catch (\ImagickException $e) {
94 | throw new RuntimeException('Failed to sharpen the image');
95 | }
96 |
97 | return $this;
98 | }
99 |
100 | /**
101 | * {@inheritdoc}
102 | */
103 | public function blur($sigma = 1)
104 | {
105 | try {
106 | $this->imagick->gaussianBlurImage(0, $sigma);
107 | } catch (\ImagickException $e) {
108 | throw new RuntimeException('Failed to blur the image', $e->getCode(), $e);
109 | }
110 |
111 | return $this;
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gd/Effects.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gd;
13 |
14 | use Imagine\Effects\EffectsInterface;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 | use Imagine\Image\Palette\Color\RGB as RGBColor;
18 |
19 | /**
20 | * Effects implementation using the GD library
21 | */
22 | class Effects implements EffectsInterface
23 | {
24 | private $resource;
25 |
26 | public function __construct($resource)
27 | {
28 | $this->resource = $resource;
29 | }
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function gamma($correction)
35 | {
36 | if (false === imagegammacorrect($this->resource, 1.0, $correction)) {
37 | throw new RuntimeException('Failed to apply gamma correction to the image');
38 | }
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * {@inheritdoc}
45 | */
46 | public function negative()
47 | {
48 | if (false === imagefilter($this->resource, IMG_FILTER_NEGATE)) {
49 | throw new RuntimeException('Failed to negate the image');
50 | }
51 |
52 | return $this;
53 | }
54 |
55 | /**
56 | * {@inheritdoc}
57 | */
58 | public function grayscale()
59 | {
60 | if (false === imagefilter($this->resource, IMG_FILTER_GRAYSCALE)) {
61 | throw new RuntimeException('Failed to grayscale the image');
62 | }
63 |
64 | return $this;
65 | }
66 |
67 | /**
68 | * {@inheritdoc}
69 | */
70 | public function colorize(ColorInterface $color)
71 | {
72 | if (!$color instanceof RGBColor) {
73 | throw new RuntimeException('Colorize effects only accepts RGB color in GD context');
74 | }
75 |
76 | if (false === imagefilter($this->resource, IMG_FILTER_COLORIZE, $color->getRed(), $color->getGreen(), $color->getBlue())) {
77 | throw new RuntimeException('Failed to colorize the image');
78 | }
79 |
80 | return $this;
81 | }
82 |
83 | /**
84 | * {@inheritdoc}
85 | */
86 | public function sharpen()
87 | {
88 | $sharpenMatrix = array(array(-1,-1,-1), array(-1,16,-1), array(-1,-1,-1));
89 | $divisor = array_sum(array_map('array_sum', $sharpenMatrix));
90 |
91 | if (false === imageconvolution($this->resource, $sharpenMatrix, $divisor, 0)) {
92 | throw new RuntimeException('Failed to sharpen the image');
93 | }
94 |
95 | return $this;
96 | }
97 |
98 | /**
99 | * {@inheritdoc}
100 | */
101 | public function blur($sigma = 1)
102 | {
103 | if (false === imagefilter($this->resource, IMG_FILTER_GAUSSIAN_BLUR)) {
104 | throw new RuntimeException('Failed to blur the image');
105 | }
106 |
107 | return $this;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gd/Layers.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gd;
13 |
14 | use Imagine\Image\AbstractLayers;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Image\Metadata\MetadataBag;
17 | use Imagine\Image\Palette\PaletteInterface;
18 | use Imagine\Exception\NotSupportedException;
19 |
20 | class Layers extends AbstractLayers
21 | {
22 | private $image;
23 | private $offset;
24 | private $resource;
25 | private $palette;
26 |
27 | public function __construct(Image $image, PaletteInterface $palette, $resource)
28 | {
29 | if (!is_resource($resource)) {
30 | throw new RuntimeException('Invalid Gd resource provided');
31 | }
32 |
33 | $this->image = $image;
34 | $this->resource = $resource;
35 | $this->offset = 0;
36 | $this->palette = $palette;
37 | }
38 |
39 | /**
40 | * {@inheritdoc}
41 | */
42 | public function merge()
43 | {
44 | }
45 |
46 | /**
47 | * {@inheritdoc}
48 | */
49 | public function coalesce()
50 | {
51 | }
52 |
53 | /**
54 | * {@inheritdoc}
55 | */
56 | public function animate($format, $delay, $loops)
57 | {
58 | return $this;
59 | }
60 |
61 | /**
62 | * {@inheritdoc}
63 | */
64 | public function current()
65 | {
66 | return new Image($this->resource, $this->palette, new MetadataBag());
67 | }
68 |
69 | /**
70 | * {@inheritdoc}
71 | */
72 | public function key()
73 | {
74 | return $this->offset;
75 | }
76 |
77 | /**
78 | * {@inheritdoc}
79 | */
80 | public function next()
81 | {
82 | ++$this->offset;
83 | }
84 |
85 | /**
86 | * {@inheritdoc}
87 | */
88 | public function rewind()
89 | {
90 | $this->offset = 0;
91 | }
92 |
93 | /**
94 | * {@inheritdoc}
95 | */
96 | public function valid()
97 | {
98 | return $this->offset < 1;
99 | }
100 |
101 | /**
102 | * {@inheritdoc}
103 | */
104 | public function count()
105 | {
106 | return 1;
107 | }
108 |
109 | /**
110 | * {@inheritdoc}
111 | */
112 | public function offsetExists($offset)
113 | {
114 | return 0 === $offset;
115 | }
116 |
117 | /**
118 | * {@inheritdoc}
119 | */
120 | public function offsetGet($offset)
121 | {
122 | if (0 === $offset) {
123 | return new Image($this->resource, $this->palette, new MetadataBag());
124 | }
125 |
126 | throw new RuntimeException('GD only supports one layer at offset 0');
127 | }
128 |
129 | /**
130 | * {@inheritdoc}
131 | */
132 | public function offsetSet($offset, $value)
133 | {
134 | throw new NotSupportedException('GD does not support layer set');
135 | }
136 |
137 | /**
138 | * {@inheritdoc}
139 | */
140 | public function offsetUnset($offset)
141 | {
142 | throw new NotSupportedException('GD does not support layer unset');
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Gmagick/RImagine.php:
--------------------------------------------------------------------------------
1 | getWidth();
30 | $height = $size->getHeight();
31 |
32 | if ($color === null) {
33 | $palette = self::$rgb;
34 | $color = '#ffffff';
35 | $alpha = 0;
36 | }
37 | else {
38 | $palette = $color->getPalette();
39 | $alpha = $color->getAlpha() / 100;
40 | }
41 |
42 | try {
43 | $pixel = new \GmagickPixel((string) $color);
44 | $pixel->setcolorvalue(\Gmagick::COLOR_OPACITY, $alpha); // does nothing as of Gmagick 1.1.7RC2. Background will be fully opaque.
45 |
46 | $magick = new \Gmagick();
47 | $magick->newimage($width, $height, $pixel->getcolor(false));
48 | $magick->setimagecolorspace(\Gmagick::COLORSPACE_TRANSPARENT);
49 | $magick->setimagebackgroundcolor($pixel);
50 |
51 | return new RImage($magick, $palette, self::$emptyBag, array($width, $height));
52 | }
53 | catch (\Exception $e) {
54 | throw new \Imagine\Exception\RuntimeException("Gmagick: could not create empty image. {$e->getMessage()}", $e->getCode(), $e);
55 | }
56 | }
57 |
58 |
59 | static public function createPalette($cs) {
60 | if ($cs === \Gmagick::COLORSPACE_SRGB || $cs === \Gmagick::COLORSPACE_RGB)
61 | return self::$rgb;
62 | elseif ($cs === \Gmagick::COLORSPACE_CMYK)
63 | return new \Imagine\Image\Palette\CMYK();
64 | elseif ($cs === \Gmagick::COLORSPACE_GRAY)
65 | return new \Imagine\Image\Palette\Grayscale();
66 | else
67 | throw new \Imagine\Exception\RuntimeException('Gmagick: Only RGB, CMYK and Grayscale colorspaces are curently supported');
68 | }
69 |
70 |
71 | public function load($string) {
72 | try {
73 | $magick = new \Gmagick();
74 | $magick->readimageblob($string);
75 | $palette = self::createPalette($magick->getImageColorspace());
76 | }
77 | catch (\GmagickException $e) {
78 | throw new RuntimeException("Gmagick: Could not load image from string. {$e->getMessage()}", $e->getCode(), $e);
79 | }
80 | return new RImage($magick, $palette, self::$emptyBag);
81 | }
82 |
83 |
84 | public function read($resource) {
85 | if (!is_resource($resource)) {
86 | throw new InvalidArgumentException('Variable does not contain a stream resource');
87 | }
88 |
89 | $content = stream_get_contents($resource);
90 |
91 | if (false === $content) {
92 | throw new InvalidArgumentException('Gmagick: Couldn\'t read given resource');
93 | }
94 |
95 | return $this->load($content);
96 | }
97 |
98 |
99 | public function font($file, $size, ColorInterface $color) {
100 | $magick = new \Gmagick();
101 | $magick->newimage(1, 1, 'transparent');
102 | return new \Imagine\Gmagick\Font($magick, $file, $size, $color);
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/Grayscale.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette;
13 |
14 | use Imagine\Image\Palette\Color\Gray as GrayColor;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 | use Imagine\Image\ProfileInterface;
17 | use Imagine\Image\Profile;
18 | use Imagine\Exception\RuntimeException;
19 |
20 | class Grayscale implements PaletteInterface
21 | {
22 | /**
23 | * @var ColorParser
24 | */
25 | private $parser;
26 |
27 | /**
28 | * @var ProfileInterface
29 | */
30 | protected $profile;
31 |
32 | /**
33 | * @var array
34 | */
35 | protected static $colors = array();
36 |
37 | public function __construct()
38 | {
39 | $this->parser = new ColorParser();
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | public function name()
46 | {
47 | return PaletteInterface::PALETTE_GRAYSCALE;
48 | }
49 |
50 | /**
51 | * {@inheritdoc}
52 | */
53 | public function pixelDefinition()
54 | {
55 | return array(ColorInterface::COLOR_GRAY);
56 | }
57 |
58 | /**
59 | * {@inheritdoc}
60 | */
61 | public function supportsAlpha()
62 | {
63 | return true;
64 | }
65 |
66 | /**
67 | * {@inheritdoc}
68 | */
69 | public function useProfile(ProfileInterface $profile)
70 | {
71 | $this->profile = $profile;
72 |
73 | return $this;
74 | }
75 |
76 | /**
77 | * {@inheritdoc}
78 | */
79 | public function profile()
80 | {
81 | if (!$this->profile) {
82 | $this->profile = Profile::fromPath(__DIR__ . '/../../resources/colormanagement.org/ISOcoated_v2_grey1c_bas.ICC');
83 | }
84 |
85 | return $this->profile;
86 | }
87 |
88 | /**
89 | * {@inheritdoc}
90 | */
91 | public function color($color, $alpha = null)
92 | {
93 | if (null === $alpha) {
94 | $alpha = 0;
95 | }
96 |
97 | $color = $this->parser->parseToGrayscale($color);
98 | $index = sprintf('#%02x%02x%02x-%d', $color[0], $color[0], $color[0], $alpha);
99 |
100 | if (false === array_key_exists($index, static::$colors)) {
101 | static::$colors[$index] = new GrayColor($this, $color, $alpha);
102 | }
103 |
104 | return static::$colors[$index];
105 | }
106 |
107 | /**
108 | * {@inheritdoc}
109 | */
110 | public function blend(ColorInterface $color1, ColorInterface $color2, $amount)
111 | {
112 | if (!$color1 instanceof GrayColor || ! $color2 instanceof GrayColor) {
113 | throw new RuntimeException('Grayscale palette can only blend Grayscale colors');
114 | }
115 |
116 | return $this->color(
117 | array(
118 | (int) min(255, min($color1->getGray(), $color2->getGray()) + round(abs($color2->getGray() - $color1->getGray()) * $amount)),
119 | ),
120 | (int) min(100, min($color1->getAlpha(), $color2->getAlpha()) + round(abs($color2->getAlpha() - $color1->getAlpha()) * $amount))
121 | );
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/CMYK.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette;
13 |
14 | use Imagine\Image\Palette\Color\CMYK as CMYKColor;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 | use Imagine\Exception\RuntimeException;
17 | use Imagine\Exception\InvalidArgumentException;
18 | use Imagine\Image\Profile;
19 | use Imagine\Image\ProfileInterface;
20 |
21 | class CMYK implements PaletteInterface
22 | {
23 | private $parser;
24 | private $profile;
25 | private static $colors = array();
26 |
27 | public function __construct()
28 | {
29 | $this->parser = new ColorParser();
30 | }
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function name()
36 | {
37 | return PaletteInterface::PALETTE_CMYK;
38 | }
39 |
40 | /**
41 | * {@inheritdoc}
42 | */
43 | public function pixelDefinition()
44 | {
45 | return array(
46 | ColorInterface::COLOR_CYAN,
47 | ColorInterface::COLOR_MAGENTA,
48 | ColorInterface::COLOR_YELLOW,
49 | ColorInterface::COLOR_KEYLINE,
50 | );
51 | }
52 |
53 | /**
54 | * {@inheritdoc}
55 | */
56 | public function supportsAlpha()
57 | {
58 | return false;
59 | }
60 |
61 | /**
62 | * {@inheritdoc}
63 | */
64 | public function color($color, $alpha = null)
65 | {
66 | if (null !== $alpha) {
67 | throw new InvalidArgumentException('CMYK palette does not support alpha');
68 | }
69 |
70 | $color = $this->parser->parseToCMYK($color);
71 | $index = sprintf('cmyk(%d, %d, %d, %d)', $color[0], $color[1], $color[2], $color[3]);
72 |
73 | if (false === array_key_exists($index, self::$colors)) {
74 | self::$colors[$index] = new CMYKColor($this, $color);
75 | }
76 |
77 | return self::$colors[$index];
78 | }
79 |
80 | /**
81 | * {@inheritdoc}
82 | */
83 | public function blend(ColorInterface $color1, ColorInterface $color2, $amount)
84 | {
85 | if (!$color1 instanceof CMYKColor || ! $color2 instanceof CMYKColor) {
86 | throw new RuntimeException('CMYK palette can only blend CMYK colors');
87 | }
88 |
89 | return $this->color(array(
90 | min(100, $color1->getCyan() + $color2->getCyan() * $amount),
91 | min(100, $color1->getMagenta() + $color2->getMagenta() * $amount),
92 | min(100, $color1->getYellow() + $color2->getYellow() * $amount),
93 | min(100, $color1->getKeyline() + $color2->getKeyline() * $amount),
94 | ));
95 | }
96 |
97 | /**
98 | * {@inheritdoc}
99 | */
100 | public function useProfile(ProfileInterface $profile)
101 | {
102 | $this->profile = $profile;
103 |
104 | return $this;
105 | }
106 |
107 | /**
108 | * {@inheritdoc}
109 | */
110 | public function profile()
111 | {
112 | if (!$this->profile) {
113 | $this->profile = Profile::fromPath(__DIR__ . '/../../resources/Adobe/CMYK/USWebUncoated.icc');
114 | }
115 |
116 | return $this->profile;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Imagick/RImagine.php:
--------------------------------------------------------------------------------
1 | getWidth();
30 | $height = $size->getHeight();
31 |
32 | $color = self::getColor($color);
33 |
34 | try {
35 | $pixel = new \ImagickPixel($color['color']);
36 | $pixel->setColorValue(\Imagick::COLOR_OPACITY, $color['alpha']);
37 |
38 | $magick = new \Imagick();
39 | $magick->newImage($width, $height, $pixel);
40 | $magick->setImageMatte(true);
41 | $magick->setImageBackgroundColor($pixel);
42 |
43 | $pixel->clear();
44 | $pixel->destroy();
45 |
46 | return new RImage($magick, $color['palette'], self::$emptyBag, array($width, $height));
47 | }
48 | catch (\Exception $e) {
49 | throw new \Imagine\Exception\RuntimeException("Imagick: Could not create empty image {$e->getMessage()}", $e->getCode(), $e);
50 | }
51 | }
52 |
53 |
54 | static public function createPalette($cs) {
55 | if ($cs === \Imagick::COLORSPACE_SRGB || $cs === \Imagick::COLORSPACE_RGB)
56 | return self::$rgb;
57 | elseif ($cs === \Imagick::COLORSPACE_CMYK)
58 | return new \Imagine\Image\Palette\CMYK();
59 | elseif ($cs === \Imagick::COLORSPACE_GRAY)
60 | return new \Imagine\Image\Palette\Grayscale();
61 | else
62 | throw new \Imagine\Exception\RuntimeException('Imagick: Only RGB, CMYK and Grayscale colorspaces are curently supported');
63 | }
64 |
65 |
66 | static public function getColor($color) {
67 | if ($color === null) {
68 | $palette = self::$rgb;
69 | $color = '#ffffff';
70 | $alpha = 0;
71 | }
72 | else {
73 | $palette = $color->getPalette();
74 | $alpha = $color->getAlpha() / 100;
75 | }
76 | return array(
77 | 'palette' => $palette,
78 | 'color' => (string) $color,
79 | 'alpha' => $alpha
80 | );
81 | }
82 |
83 |
84 | public function load($string) {
85 | try {
86 | $magick = new \Imagick();
87 | $magick->readImageBlob($string);
88 | $magick->setImageMatte(true);
89 | $palette = self::createPalette($magick->getImageColorspace());
90 | }
91 | catch (\ImagickException $e) {
92 | throw new RuntimeException("Imagick: Could not load image from string. {$e->getMessage()}", $e->getCode(), $e);
93 | }
94 | return new RImage($magick, $palette, self::$emptyBag);
95 | }
96 |
97 |
98 | public function read($resource) {
99 | if (!is_resource($resource)) {
100 | throw new InvalidArgumentException('Variable does not contain a stream resource');
101 | }
102 |
103 | try {
104 | $magick = new \Imagick();
105 | $magick->readImageFile($resource);
106 | }
107 | catch (\ImagickException $e) {
108 | throw new RuntimeException("Imagick: Could not read image from resource. {$e->getMessage()}", $e->getCode(), $e);
109 | }
110 |
111 | $palette = self::createPalette($magick->getImageColorspace());
112 | return new RImage($magick, $palette, self::$emptyBag);
113 | }
114 |
115 |
116 | public function font($file, $size, ColorInterface $color) {
117 | return new \Imagine\Imagick\Font(new \Imagick(), $file, $size, $color);
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/RGB.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette;
13 |
14 | use Imagine\Image\Palette\Color\RGB as RGBColor;
15 | use Imagine\Image\Palette\Color\ColorInterface;
16 | use Imagine\Image\ProfileInterface;
17 | use Imagine\Image\Profile;
18 | use Imagine\Exception\RuntimeException;
19 |
20 | class RGB implements PaletteInterface
21 | {
22 | /**
23 | * @var ColorParser
24 | */
25 | private $parser;
26 |
27 | /**
28 | * @var ProfileInterface
29 | */
30 | protected $profile;
31 |
32 | /**
33 | * @var array
34 | */
35 | protected static $colors = array();
36 |
37 | public function __construct()
38 | {
39 | $this->parser = new ColorParser();
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | public function name()
46 | {
47 | return PaletteInterface::PALETTE_RGB;
48 | }
49 |
50 | /**
51 | * {@inheritdoc}
52 | */
53 | public function pixelDefinition()
54 | {
55 | return array(
56 | ColorInterface::COLOR_RED,
57 | ColorInterface::COLOR_GREEN,
58 | ColorInterface::COLOR_BLUE,
59 | );
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | public function supportsAlpha()
66 | {
67 | return true;
68 | }
69 |
70 | /**
71 | * {@inheritdoc}
72 | */
73 | public function useProfile(ProfileInterface $profile)
74 | {
75 | $this->profile = $profile;
76 |
77 | return $this;
78 | }
79 |
80 | /**
81 | * {@inheritdoc}
82 | */
83 | public function profile()
84 | {
85 | if (!$this->profile) {
86 | $this->profile = Profile::fromPath(__DIR__ . '/../../resources/color.org/sRGB_IEC61966-2-1_black_scaled.icc');
87 | }
88 |
89 | return $this->profile;
90 | }
91 |
92 | /**
93 | * {@inheritdoc}
94 | */
95 | public function color($color, $alpha = null)
96 | {
97 | if (null === $alpha) {
98 | $alpha = 100;
99 | }
100 |
101 | $color = $this->parser->parseToRGB($color);
102 | $index = sprintf('#%02x%02x%02x-%d', $color[0], $color[1], $color[2], $alpha);
103 |
104 | if (false === array_key_exists($index, static::$colors)) {
105 | static::$colors[$index] = new RGBColor($this, $color, $alpha);
106 | }
107 |
108 | return static::$colors[$index];
109 | }
110 |
111 | /**
112 | * {@inheritdoc}
113 | */
114 | public function blend(ColorInterface $color1, ColorInterface $color2, $amount)
115 | {
116 | if (!$color1 instanceof RGBColor || ! $color2 instanceof RGBColor) {
117 | throw new RuntimeException('RGB palette can only blend RGB colors');
118 | }
119 |
120 | return $this->color(
121 | array(
122 | (int) min(255, min($color1->getRed(), $color2->getRed()) + round(abs($color2->getRed() - $color1->getRed()) * $amount)),
123 | (int) min(255, min($color1->getGreen(), $color2->getGreen()) + round(abs($color2->getGreen() - $color1->getGreen()) * $amount)),
124 | (int) min(255, min($color1->getBlue(), $color2->getBlue()) + round(abs($color2->getBlue() - $color1->getBlue()) * $amount)),
125 | ),
126 | (int) min(100, min($color1->getAlpha(), $color2->getAlpha()) + round(abs($color2->getAlpha() - $color1->getAlpha()) * $amount))
127 | );
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/AbstractImage.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 | use Imagine\Image\Metadata\MetadataBag;
16 |
17 | abstract class AbstractImage implements ImageInterface
18 | {
19 | /**
20 | * @var MetadataBag
21 | */
22 | protected $metadata;
23 |
24 | /**
25 | * {@inheritdoc}
26 | */
27 | public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
28 | {
29 | if ($mode !== ImageInterface::THUMBNAIL_INSET &&
30 | $mode !== ImageInterface::THUMBNAIL_OUTBOUND) {
31 | throw new InvalidArgumentException('Invalid mode specified');
32 | }
33 |
34 | $imageSize = $this->getSize();
35 | $ratios = array(
36 | $size->getWidth() / $imageSize->getWidth(),
37 | $size->getHeight() / $imageSize->getHeight()
38 | );
39 |
40 | $thumbnail = $this->copy();
41 |
42 | $thumbnail->usePalette($this->palette());
43 | $thumbnail->strip();
44 | // if target width is larger than image width
45 | // AND target height is longer than image height
46 | if ($size->contains($imageSize)) {
47 | return $thumbnail;
48 | }
49 |
50 | if ($mode === ImageInterface::THUMBNAIL_INSET) {
51 | $ratio = min($ratios);
52 | } else {
53 | $ratio = max($ratios);
54 | }
55 |
56 | if ($mode === ImageInterface::THUMBNAIL_OUTBOUND) {
57 | if (!$imageSize->contains($size)) {
58 | $size = new Box(
59 | min($imageSize->getWidth(), $size->getWidth()),
60 | min($imageSize->getHeight(), $size->getHeight())
61 | );
62 | } else {
63 | $imageSize = $thumbnail->getSize()->scale($ratio);
64 | $thumbnail->resize($imageSize, $filter);
65 | }
66 | $thumbnail->crop(new Point(
67 | max(0, round(($imageSize->getWidth() - $size->getWidth()) / 2)),
68 | max(0, round(($imageSize->getHeight() - $size->getHeight()) / 2))
69 | ), $size);
70 | } else {
71 | if (!$imageSize->contains($size)) {
72 | $imageSize = $imageSize->scale($ratio);
73 | $thumbnail->resize($imageSize, $filter);
74 | } else {
75 | $imageSize = $thumbnail->getSize()->scale($ratio);
76 | $thumbnail->resize($imageSize, $filter);
77 | }
78 | }
79 |
80 | return $thumbnail;
81 | }
82 |
83 | /**
84 | * Updates a given array of save options for backward compatibility with legacy names
85 | *
86 | * @param array $options
87 | *
88 | * @return array
89 | */
90 | protected function updateSaveOptions(array $options)
91 | {
92 | // Preserve BC until version 1.0
93 | if (isset($options['quality']) && !isset($options['jpeg_quality'])) {
94 | $options['jpeg_quality'] = $options['quality'];
95 | }
96 |
97 | return $options;
98 | }
99 |
100 | /**
101 | * {@inheritdoc}
102 | */
103 | public function metadata()
104 | {
105 | return $this->metadata;
106 | }
107 |
108 | /**
109 | * Assures the metadata instance will be cloned, too
110 | */
111 | public function __clone()
112 | {
113 | if ($this->metadata !== null) {
114 | $this->metadata = clone $this->metadata;
115 | }
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Imagick/RImage.php:
--------------------------------------------------------------------------------
1 | image = new Image($resource, $palette, $metadata);
17 | if (is_array($size)) { $this->size = $size; }
18 | else {
19 | $size = $this->image->getSize();
20 | $this->size = array($size->getWidth(), $size->getHeight());
21 | }
22 | }
23 | }
24 |
25 |
26 | public function resize(BoxInterface $size, $filter = null) {
27 | $width = $size->getWidth();
28 | $height = $size->getHeight();
29 | if ($this->image === null) { $this->load(array($width, $height)); }
30 |
31 | $this->image->getImagick()->thumbnailImage($width, $height);
32 | $this->size = array($width, $height);
33 |
34 | return $this;
35 | }
36 |
37 |
38 | public function crop(PointInterface $start, BoxInterface $size) {
39 | if ($this->image === null) { $this->load(); }
40 |
41 | $width = $size->getWidth();
42 | $height = $size->getHeight();
43 |
44 | $magick = $this->image->getImagick();
45 | try {
46 | $magick->cropImage($width, $height, $start->getX(), $start->getY());
47 | $magick->setImagePage(0, 0, 0, 0); // Reset canvas for gif format
48 | }
49 | catch (\ImagickException $e) {
50 | throw new \Imagine\Exception\RuntimeException('Imagick: Crop operation failed', $e->getCode(), $e);
51 | }
52 | $this->size = array($width, $height);
53 |
54 | return $this;
55 | }
56 |
57 |
58 | public function rotate($angle, \Imagine\Image\Palette\Color\ColorInterface $background = null) {
59 | if ($this->image === null) { $this->load(); }
60 |
61 | $color = RImagine::getColor($background);
62 |
63 | try {
64 | $pixel = new \ImagickPixel($color['color']);
65 | $pixel->setColorValue(\Imagick::COLOR_OPACITY, $color['alpha']);
66 |
67 | $magick = $this->image->getImagick();
68 | $magick->rotateimage($pixel, $angle);
69 | $pixel->clear();
70 | $pixel->destroy();
71 | $magick->setImagePage(0, 0, 0, 0); // reset canvas position
72 | }
73 | catch (\ImagickException $e) {
74 | throw new \Imagine\Exception\RuntimeException('Imagick: Rotate operation failed. ' . $e->getMessage(), $e->getCode(), $e);
75 | }
76 |
77 | $this->size = array($magick->getImageWidth(), $magick->getImageHeight());
78 |
79 | return $this;
80 | }
81 |
82 |
83 | public function fade($opacity) {
84 | if ($this->image === null) { $this->load(); }
85 |
86 | $this->image->getImagick()->setImageOpacity($opacity);
87 | }
88 |
89 |
90 | protected function load($size = null) {
91 | try {
92 | $magick = new \Imagick();
93 | if ($this->format === IMG_JPG && $size !== null) {
94 | $magick->setOption('jpeg:size', $size[0] . 'x' . $size[1]); // some versions of Imagick only respond to this...
95 | $magick->setSize($size[0], $size[1]); // ...and others to this
96 | }
97 | $magick->readImage($this->filename);
98 | }
99 | catch (\Exception $e) {
100 | throw new \Imagine\Exception\RuntimeException("Imagick: Unable to open image {$this->filename}. {$e->getMessage()}", $e->getCode(), $e);
101 | }
102 | if ($this->format === IMG_JPG && $size !== null) {
103 | $newWidth = $magick->getImageWidth();
104 | if ($newWidth !== $this->size[0]) {
105 | $this->size = $this->prescalesize = array($newWidth, $magick->getImageHeight());
106 | }
107 | }
108 | $cs = $magick->getImageColorspace();
109 | $this->image = new Image($magick, RImagine::createPalette($cs), $this->metadata);
110 |
111 | if ($cs === \Imagick::COLORSPACE_CMYK) { // convert CMYK > RGB
112 | try {
113 | $this->image->usePalette(new RGB());
114 | }
115 | catch (\Exception $e) {
116 | $this->image->getImagick()->stripimage(); // make sure all profiles are removed
117 | }
118 | }
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/Color/Gray.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette\Color;
13 |
14 | use Imagine\Image\Palette\Grayscale;
15 | use Imagine\Exception\InvalidArgumentException;
16 |
17 | final class Gray implements ColorInterface
18 | {
19 | /**
20 | * @var integer
21 | */
22 | private $gray;
23 |
24 | /**
25 | * @var integer
26 | */
27 | private $alpha;
28 |
29 | /**
30 | *
31 | * @var Grayscale
32 | */
33 | private $palette;
34 |
35 | public function __construct(Grayscale $palette, array $color, $alpha)
36 | {
37 | $this->palette = $palette;
38 | $this->setColor($color);
39 | $this->setAlpha($alpha);
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | public function getValue($component)
46 | {
47 | switch ($component) {
48 | case ColorInterface::COLOR_GRAY:
49 | return $this->getGray();
50 | default:
51 | throw new InvalidArgumentException(sprintf('Color component %s is not valid', $component));
52 | }
53 | }
54 |
55 | /**
56 | * Returns Gray value of the color
57 | *
58 | * @return integer
59 | */
60 | public function getGray()
61 | {
62 | return $this->gray;
63 | }
64 |
65 | /**
66 | * {@inheritdoc}
67 | */
68 | public function getPalette()
69 | {
70 | return $this->palette;
71 | }
72 |
73 | /**
74 | * {@inheritdoc}
75 | */
76 | public function getAlpha()
77 | {
78 | return $this->alpha;
79 | }
80 |
81 | /**
82 | * {@inheritdoc}
83 | */
84 | public function dissolve($alpha)
85 | {
86 | return $this->palette->color(
87 | array($this->gray), $this->alpha + $alpha
88 | );
89 | }
90 |
91 | /**
92 | * {@inheritdoc}
93 | */
94 | public function lighten($shade)
95 | {
96 | return $this->palette->color(array(min(255, $this->gray + $shade)), $this->alpha);
97 | }
98 |
99 | /**
100 | * {@inheritdoc}
101 | */
102 | public function darken($shade)
103 | {
104 | return $this->palette->color(array(max(0, $this->gray - $shade)), $this->alpha);
105 | }
106 |
107 | /**
108 | * {@inheritdoc}
109 | */
110 | public function grayscale()
111 | {
112 | return $this;
113 | }
114 |
115 | /**
116 | * {@inheritdoc}
117 | */
118 | public function isOpaque()
119 | {
120 | return 100 === $this->alpha;
121 | }
122 |
123 | /**
124 | * Returns hex representation of the color
125 | *
126 | * @return string
127 | */
128 | public function __toString()
129 | {
130 | return sprintf('#%02x%02x%02x', $this->gray, $this->gray, $this->gray);
131 | }
132 |
133 | /**
134 | * Performs checks for validity of given alpha value and sets it
135 | *
136 | * @param integer $alpha
137 | *
138 | * @throws InvalidArgumentException
139 | */
140 | private function setAlpha($alpha)
141 | {
142 | if (!is_int($alpha) || $alpha < 0 || $alpha > 100) {
143 | throw new InvalidArgumentException(sprintf('Alpha must be an integer between 0 and 100, %s given', $alpha));
144 | }
145 |
146 | $this->alpha = $alpha;
147 | }
148 |
149 | /**
150 | * Performs checks for color validity (array of array(gray))
151 | *
152 | * @param array $color
153 | *
154 | * @throws InvalidArgumentException
155 | */
156 | private function setColor(array $color)
157 | {
158 | if (count($color) !== 1) {
159 | throw new InvalidArgumentException('Color argument must look like array(gray), where gray is the integer value between 0 and 255 for the grayscale');
160 | }
161 |
162 | list($this->gray) = array_values($color);
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/_build/validators/resizer.validator.php:
--------------------------------------------------------------------------------
1 | xpdo) {
29 | $modx =& $object->xpdo;
30 | switch ($options[xPDOTransport::PACKAGE_ACTION]) {
31 | case xPDOTransport::ACTION_UPGRADE:
32 | // move an existing non-default jpeg quality setting into the new global options
33 | $graphicsLib = $modx->getOption('resizer.graphics_library', null, false);
34 | if ($graphicsLib == 1) {
35 | $setting = $modx->getObject('modSystemSetting', 'resizer.graphics_library');
36 | $setting->set('value', 2);
37 | $setting->save();
38 | }
39 | case xPDOTransport::ACTION_INSTALL:
40 | /* return false if conditions are not met */
41 | $modx->log(xPDO::LOG_LEVEL_INFO, '[Resizer]');
42 | if (version_compare(PHP_VERSION, '5.3.2', '>=')) {
43 | $phpver = true;
44 | $modx->log(xPDO::LOG_LEVEL_INFO, 'PHP version: ' . PHP_VERSION . ' [OK]');
45 | }
46 | else {
47 | $phpver = false;
48 | $modx->log(xPDO::LOG_LEVEL_INFO, 'PHP version: ' . PHP_VERSION);
49 | $modx->log(xPDO::LOG_LEVEL_ERROR, 'Resizer requires PHP 5.3.2 or higher');
50 | }
51 |
52 | $graphicsSuccess = false;
53 | $modx->log(xPDO::LOG_LEVEL_INFO,'Availabe graphics libraries:');
54 |
55 | if (class_exists('Gmagick', false)) {
56 | $magick = new Gmagick();
57 | $version = $magick->getversion();
58 | $modx->log(xPDO::LOG_LEVEL_INFO, "* {$version['versionString']}");
59 | $graphicsSuccess = true;
60 | }
61 |
62 | if (class_exists('Imagick', false)) {
63 | $magick = new \Imagick();
64 | $v = $magick->getVersion();
65 | $modx->log(xPDO::LOG_LEVEL_INFO, "* {$v['versionString']}");
66 | list($version, $year, $month, $day, $q, $website) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
67 | $version = explode('-', $version);
68 | $version = $version[0];
69 | if (version_compare('6.2.9', $version) > 0) {
70 | $modx->log(xPDO::LOG_LEVEL_ERROR, '- ImageMagick 6.2.9 or higher required. Disabling Imagick support.');
71 | $setting = $modx->getObject('modSystemSetting', 'resizer.graphics_library');
72 | $setting->set('value', 0);
73 | $setting->save();
74 | }
75 | else {
76 | $graphicsSuccess = true;
77 | if (version_compare('6.5.7', $version) > 0) {
78 | $modx->log(xPDO::LOG_LEVEL_ERROR, '- ImageMagick < 6.5.7: CMYK to RGB conversions not supported');
79 | }
80 | if (version_compare('6.5.4', $version) == 0) {
81 | $modx->log(xPDO::LOG_LEVEL_ERROR, '- ImageMagick 6.5.4: buggy rotation. Affects rotated watermarks.');
82 | }
83 | }
84 | }
85 |
86 | if (function_exists('gd_info')) {
87 | $version = gd_info();
88 | $modx->log(xPDO::LOG_LEVEL_INFO, "* GD: {$version['GD Version']}");
89 | if (version_compare(GD_VERSION, '2.0.1', '<')) {
90 | $modx->log(xPDO::LOG_LEVEL_ERROR, '-- GD 2.0.1 or higher required');
91 | }
92 | else {
93 | $graphicsSuccess = true;
94 | }
95 | }
96 | if (!$graphicsSuccess) {
97 | $modx->log(xPDO::LOG_LEVEL_ERROR, 'Resizer requires one of the following PHP extensions: Imagick, Gmagick, GD.');
98 | }
99 | return $phpver && $graphicsSuccess;
100 | break;
101 |
102 | case xPDOTransport::ACTION_UNINSTALL:
103 | break;
104 | }
105 | }
106 |
107 | return true;
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/resources/SIL Open Font License.txt:
--------------------------------------------------------------------------------
1 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
2 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
3 |
4 | -----------------------------------------------------------
5 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
6 | -----------------------------------------------------------
7 |
8 | PREAMBLE
9 | The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
10 |
11 | The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
12 |
13 | DEFINITIONS
14 | "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
15 |
16 | "Reserved Font Name" refers to any names specified as such after the copyright statement(s).
17 |
18 | "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
19 |
20 | "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
21 |
22 | "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
23 |
24 | PERMISSION & CONDITIONS
25 | Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
26 |
27 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
28 |
29 | 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
30 |
31 | 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
32 |
33 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
34 |
35 | 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
36 |
37 | TERMINATION
38 | This license becomes null and void if any of the above conditions are not met.
39 |
40 | DISCLAIMER
41 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/ImageInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Draw\DrawerInterface;
15 | use Imagine\Effects\EffectsInterface;
16 | use Imagine\Image\Palette\PaletteInterface;
17 | use Imagine\Image\Palette\Color\ColorInterface;
18 | use Imagine\Exception\RuntimeException;
19 | use Imagine\Exception\OutOfBoundsException;
20 |
21 | /**
22 | * The image interface
23 | */
24 | interface ImageInterface extends ManipulatorInterface
25 | {
26 | const RESOLUTION_PIXELSPERINCH = 'ppi';
27 | const RESOLUTION_PIXELSPERCENTIMETER = 'ppc';
28 |
29 | const INTERLACE_NONE = 'none';
30 | const INTERLACE_LINE = 'line';
31 | const INTERLACE_PLANE = 'plane';
32 | const INTERLACE_PARTITION = 'partition';
33 |
34 | const FILTER_UNDEFINED = 'undefined';
35 | const FILTER_POINT = 'point';
36 | const FILTER_BOX = 'box';
37 | const FILTER_TRIANGLE = 'triangle';
38 | const FILTER_HERMITE = 'hermite';
39 | const FILTER_HANNING = 'hanning';
40 | const FILTER_HAMMING = 'hamming';
41 | const FILTER_BLACKMAN = 'blackman';
42 | const FILTER_GAUSSIAN = 'gaussian';
43 | const FILTER_QUADRATIC = 'quadratic';
44 | const FILTER_CUBIC = 'cubic';
45 | const FILTER_CATROM = 'catrom';
46 | const FILTER_MITCHELL = 'mitchell';
47 | const FILTER_LANCZOS = 'lanczos';
48 | const FILTER_BESSEL = 'bessel';
49 | const FILTER_SINC = 'sinc';
50 |
51 | /**
52 | * Returns the image content as a binary string
53 | *
54 | * @param string $format
55 | * @param array $options
56 | *
57 | * @throws RuntimeException
58 | *
59 | * @return string binary
60 | */
61 | public function get($format, array $options = array());
62 |
63 | /**
64 | * Returns the image content as a PNG binary string
65 | *
66 | * @throws RuntimeException
67 | *
68 | * @return string binary
69 | */
70 | public function __toString();
71 |
72 | /**
73 | * Instantiates and returns a DrawerInterface instance for image drawing
74 | *
75 | * @return DrawerInterface
76 | */
77 | public function draw();
78 |
79 | /**
80 | * @return EffectsInterface
81 | */
82 | public function effects();
83 |
84 | /**
85 | * Returns current image size
86 | *
87 | * @return BoxInterface
88 | */
89 | public function getSize();
90 |
91 | /**
92 | * Transforms creates a grayscale mask from current image, returns a new
93 | * image, while keeping the existing image unmodified
94 | *
95 | * @return ImageInterface
96 | */
97 | public function mask();
98 |
99 | /**
100 | * Returns array of image colors as Imagine\Image\Palette\Color\ColorInterface instances
101 | *
102 | * @return array
103 | */
104 | public function histogram();
105 |
106 | /**
107 | * Returns color at specified positions of current image
108 | *
109 | * @param PointInterface $point
110 | *
111 | * @throws RuntimeException
112 | *
113 | * @return ColorInterface
114 | */
115 | public function getColorAt(PointInterface $point);
116 |
117 | /**
118 | * Returns the image layers when applicable.
119 | *
120 | * @throws RuntimeException In case the layer can not be returned
121 | * @throws OutOfBoundsException In case the index is not a valid value
122 | *
123 | * @return LayersInterface
124 | */
125 | public function layers();
126 |
127 | /**
128 | * Enables or disables interlacing
129 | *
130 | * @param string $scheme
131 | *
132 | * @throws InvalidArgumentException When an unsupported Interface type is supplied
133 | *
134 | * @return ImageInterface
135 | */
136 | public function interlace($scheme);
137 |
138 | /**
139 | * Return the current color palette
140 | *
141 | * @return PaletteInterface
142 | */
143 | public function palette();
144 |
145 | /**
146 | * Set a palette for the image. Useful to change colorspace.
147 | *
148 | * @param PaletteInterface $palette
149 | *
150 | * @return ImageInterface
151 | *
152 | * @throws RuntimeException
153 | */
154 | public function usePalette(PaletteInterface $palette);
155 |
156 | /**
157 | * Applies a color profile on the Image
158 | *
159 | * @param ProfileInterface $profile
160 | *
161 | * @return ImageInterface
162 | *
163 | * @throws RuntimeException
164 | */
165 | public function profile(ProfileInterface $profile);
166 |
167 | /**
168 | * Returns the Image's meta data
169 | *
170 | * @return Metadata\MetadataInterface
171 | */
172 | public function metadata();
173 | }
174 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Draw/DrawerInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Draw;
13 |
14 | use Imagine\Image\AbstractFont;
15 | use Imagine\Image\BoxInterface;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 | use Imagine\Image\PointInterface;
18 | use Imagine\Exception\RuntimeException;
19 |
20 | /**
21 | * Interface for the drawer
22 | */
23 | interface DrawerInterface
24 | {
25 | /**
26 | * Draws an arc on a starting at a given x, y coordinates under a given
27 | * start and end angles
28 | *
29 | * @param PointInterface $center
30 | * @param BoxInterface $size
31 | * @param integer $start
32 | * @param integer $end
33 | * @param ColorInterface $color
34 | * @param integer $thickness
35 | *
36 | * @throws RuntimeException
37 | *
38 | * @return DrawerInterface
39 | */
40 | public function arc(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $thickness = 1);
41 |
42 | /**
43 | * Same as arc, but also connects end points with a straight line
44 | *
45 | * @param PointInterface $center
46 | * @param BoxInterface $size
47 | * @param integer $start
48 | * @param integer $end
49 | * @param ColorInterface $color
50 | * @param Boolean $fill
51 | * @param integer $thickness
52 | *
53 | * @throws RuntimeException
54 | *
55 | * @return DrawerInterface
56 | */
57 | public function chord(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $fill = false, $thickness = 1);
58 |
59 | /**
60 | * Draws and ellipse with center at the given x, y coordinates, and given
61 | * width and height
62 | *
63 | * @param PointInterface $center
64 | * @param BoxInterface $size
65 | * @param ColorInterface $color
66 | * @param Boolean $fill
67 | * @param integer $thickness
68 | *
69 | * @throws RuntimeException
70 | *
71 | * @return DrawerInterface
72 | */
73 | public function ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, $fill = false, $thickness = 1);
74 |
75 | /**
76 | * Draws a line from start(x, y) to end(x, y) coordinates
77 | *
78 | * @param PointInterface $start
79 | * @param PointInterface $end
80 | * @param ColorInterface $outline
81 | * @param integer $thickness
82 | *
83 | * @return DrawerInterface
84 | */
85 | public function line(PointInterface $start, PointInterface $end, ColorInterface $outline, $thickness = 1);
86 |
87 | /**
88 | * Same as arc, but connects end points and the center
89 | *
90 | * @param PointInterface $center
91 | * @param BoxInterface $size
92 | * @param integer $start
93 | * @param integer $end
94 | * @param ColorInterface $color
95 | * @param Boolean $fill
96 | * @param integer $thickness
97 | *
98 | * @throws RuntimeException
99 | *
100 | * @return DrawerInterface
101 | */
102 | public function pieSlice(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $fill = false, $thickness = 1);
103 |
104 | /**
105 | * Places a one pixel point at specific coordinates and fills it with
106 | * specified color
107 | *
108 | * @param PointInterface $position
109 | * @param ColorInterface $color
110 | *
111 | * @throws RuntimeException
112 | *
113 | * @return DrawerInterface
114 | */
115 | public function dot(PointInterface $position, ColorInterface $color);
116 |
117 | /**
118 | * Draws a polygon using array of x, y coordinates. Must contain at least
119 | * three coordinates
120 | *
121 | * @param array $coordinates
122 | * @param ColorInterface $color
123 | * @param Boolean $fill
124 | * @param integer $thickness
125 | *
126 | * @throws RuntimeException
127 | *
128 | * @return DrawerInterface
129 | */
130 | public function polygon(array $coordinates, ColorInterface $color, $fill = false, $thickness = 1);
131 |
132 | /**
133 | * Annotates image with specified text at a given position starting on the
134 | * top left of the final text box
135 | *
136 | * The rotation is done CW
137 | *
138 | * @param string $string
139 | * @param AbstractFont $font
140 | * @param PointInterface $position
141 | * @param integer $angle
142 | * @param integer $width
143 | *
144 | * @throws RuntimeException
145 | *
146 | * @return DrawerInterface
147 | */
148 | public function text($string, AbstractFont $font, PointInterface $position, $angle = 0, $width = null);
149 | }
150 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | ### 0.6.0 (2014-xx-xx)
4 |
5 | * BC break: Colors are now provided through the PaletteInterface. Any call
6 | to previous Imagine\Image\Color constructor must be removed and use the
7 | palette provided by Imagine\Image\ImageInterface::getPalette to create
8 | colors.
9 | * BC break : Animated GIF default delay is no longer 800ms but null. This
10 | avoids resettings a delay on animated image.
11 | * Add support for ICC profiles
12 | * Add support for CMYK and grayscale colorspace images.
13 | * Add filter argument to ImageInterface::thumbnail method.
14 | * Add priority to filters (@Richtermeister).
15 | * Add blur effect (@Nokrosis).
16 | * Rename "quality" option to "jpeg_quality" and apply it only to JPEG files (@vlakoff).
17 | * Add "png_compression_level" option (@vlakoff).
18 | * Rename "filters" option to "png_compression_filter" (@vlakoff).
19 | * Deprecate `quality` and `filters` ManipulatorInterface::save options, use
20 | `jpeg_quality`, `png_compression_level` and `png_compression_filter` instead.
21 | * Add support for alpha blending in GD drawer (@salem).
22 | * Add width parameter to Drawer::text (@salemgolemugoo).
23 | * Add NotSupportedException when a driver does not support an operation (@rouffj).
24 | * Add support for metadata.
25 | * Fix #158: GD alpha detection + Color::isOpaque are broken.
26 |
27 | ### 0.5.0 (2013-07-10)
28 |
29 | * Add `Layers::coalesce`.
30 | * Add filter option to `ImageInterface::resize`.
31 | * Add sharpen effect.
32 | * Add interlace support.
33 | * `LayersInterface` now extends `ArrayAccess`, gives support for animated gifs.
34 | * Remove Imagick and Gmagick flatten after composite.
35 | * Fix pixel opacity reading in `Gmagick::histogram`.
36 | * Deprecate pear channel installation.
37 | * Deprecate phar installation.
38 |
39 | ### 0.4.1 (2012-12-13)
40 |
41 | * Lazy-load GD layers.
42 |
43 | ### 0.4.0 (2012-12-10)
44 |
45 | * Add support for image Layers.
46 | * Add Colorize effect.
47 | * Add documentation for the Grayscale effect.
48 | * Port RelativeResize filter from JmikolaImagineBundle.
49 |
50 | ### 0.3.1 (2012-11-12)
51 |
52 | * Add Grayscale effect.
53 | * `Drawer::text` position fix.
54 |
55 | ### 0.3.0 (2012-07-28)
56 |
57 | * Add configurable border thickness to drawer interface and implementations.
58 | * Add `ImageInterface`::strip.
59 | * Add Canvas filter.
60 | * Add resolution option on image saving.
61 | * Add Grayscale filter.
62 | * Add sami API documentation.
63 | * Add compression quality to Gmagick.
64 | * Add effects API.
65 | * Add method to get pixel at point in Gmagick.
66 | * Ensure valid background color in rotations.
67 | * Fill lines with color to prevent semi-transparency issues.
68 | * Use `Imagick::resizeImage` instead of `Imagick::thumbnailImage` for resizing.
69 | * Fix PNG transparency on save ; do not flatten if not necessary.
70 |
71 | ### 0.2.8 (2011-11-29)
72 |
73 | * Add support for Travis CI.
74 |
75 | ### 0.2.7 (2011-11-17)
76 |
77 | * Use composer for autoloading.
78 |
79 | ### 0.2.6 (2011-11-09)
80 |
81 | * Documentation enhancements.
82 |
83 | ### 0.2.5 (2011-10-29)
84 |
85 | * Add PEAR support.
86 | * Documentation enhancements.
87 |
88 | ### 0.2.4 (2011-10-17)
89 |
90 | * Add imagine.phar, phar and rake tasks.
91 | * Add `ImagineInterface::read` to read from a stream resource.
92 | * Documentation enhancements.
93 | * Fix gifs transparency issues.
94 |
95 | ### 0.2.3 (2011-10-16)
96 |
97 | * Documentation enhancements.
98 |
99 | ### 0.2.2 (2011-10-16)
100 |
101 | * Documentation enhancements.
102 |
103 | ### 0.2.1 (2011-10-15)
104 |
105 | * Add `PointInterface::move`.
106 | * `BoxInterface::scale` can accept floats.
107 | * Set antialias mode for GD images.
108 | * Fix png compression.
109 |
110 | ### 0.2.0 (2011-10-06)
111 |
112 | * Add `Imagine\Fill\Gradient\Linear::getStart`/`getEnd`.
113 | * Add `Imagine\Image\Color::isOpaque`.
114 | * Add Gmagick transparency exceptions.
115 | * Add support for transparency for gif export.
116 | * Add widen/heighten methods for easy scaling to target width/height.
117 | * Add functionals tests to unit test thumbnails creation.
118 | * Add the ability to use hexadecimal notation for `Imagine\Image\Color` construction.
119 | * Implement fast linear gradient for Imagick.
120 | * Remove lengthy image histogram comparisons.
121 | * Extract `ManipulatorInterface` from `ImageInterface`.
122 | * Switch methods to final.
123 | * New method `ImageInterface::getColorAt`.
124 | * Introduce `ImagineAware` abstract filter class.
125 |
126 | ### 0.1.5 (2011-05-18)
127 |
128 | * Fix bug in GD rotate.
129 |
130 | ### 0.1.4 (2011-03-21)
131 |
132 | * Add environment check to gracefuly skip test.
133 |
134 | ### 0.1.3 (2011-03-21)
135 |
136 | * Improve api docs.
137 | * Extract `FontInterface`.
138 |
139 | ### 0.1.2 (2011-03-21)
140 |
141 | * Add check for GD.
142 |
143 | ### 0.1.1 (2011-03-21)
144 |
145 | * Add rounding and fixed thumbnail logic.
146 |
147 | ### 0.1.0 (2011-03-14)
148 |
149 | * First tagged version.
150 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/ColorParser.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 |
16 | class ColorParser
17 | {
18 | /**
19 | * Parses a color to a RGB tuple
20 | *
21 | * @param string|array|integer $color
22 | *
23 | * @return array
24 | *
25 | * @throws InvalidArgumentException
26 | */
27 | public function parseToRGB($color)
28 | {
29 | $color = $this->parse($color);
30 |
31 | if (4 === count($color)) {
32 | $color = array(
33 | 255 * (1 - $color[0] / 100) * (1 - $color[3] / 100),
34 | 255 * (1 - $color[1] / 100) * (1 - $color[3] / 100),
35 | 255 * (1 - $color[2] / 100) * (1 - $color[3] / 100),
36 | );
37 | }
38 |
39 | return $color;
40 | }
41 |
42 | /**
43 | * Parses a color to a CMYK tuple
44 | *
45 | * @param string|array|integer $color
46 | *
47 | * @return array
48 | *
49 | * @throws InvalidArgumentException
50 | */
51 | public function parseToCMYK($color)
52 | {
53 | $color = $this->parse($color);
54 |
55 | if (3 === count($color)) {
56 | $r = $color[0] / 255;
57 | $g = $color[1] / 255;
58 | $b = $color[2] / 255;
59 |
60 | $k = 1 - max($r, $g, $b);
61 |
62 | $color = array(
63 | 1 === $k ? 0 : round((1 - $r - $k) / (1- $k) * 100),
64 | 1 === $k ? 0 : round((1 - $g - $k) / (1- $k) * 100),
65 | 1 === $k ? 0 : round((1 - $b - $k) / (1- $k) * 100),
66 | round($k * 100)
67 | );
68 | }
69 |
70 | return $color;
71 | }
72 |
73 | /**
74 | * Parses a color to a grayscale value
75 | *
76 | * @param string|array|integer $color
77 | *
78 | * @return array
79 | *
80 | * @throws InvalidArgumentException
81 | */
82 | public function parseToGrayscale($color)
83 | {
84 | if (is_array($color) && 1 === count($color)) {
85 | return array_values($color);
86 | }
87 |
88 | $color = array_unique($this->parse($color));
89 |
90 | if (1 !== count($color)) {
91 | throw new InvalidArgumentException('The provided color has different values of red, green and blue components. Grayscale colors must have the same values for these.');
92 | }
93 |
94 | return $color;
95 | }
96 |
97 | /**
98 | * Parses a color
99 | *
100 | * @param string|array|integer $color
101 | *
102 | * @return array
103 | *
104 | * @throws InvalidArgumentException
105 | */
106 | private function parse($color)
107 | {
108 | if (!is_string($color) && !is_array($color) && !is_int($color)) {
109 | throw new InvalidArgumentException(sprintf('Color must be specified as a hexadecimal string, array or integer, %s given', gettype($color)));
110 | }
111 |
112 | if (is_array($color)) {
113 | if (3 === count($color) || 4 === count($color)) {
114 | return array_values($color);
115 | }
116 | throw new InvalidArgumentException('Color argument if array, must look like array(R, G, B), or array(C, M, Y, K) where R, G, B are the integer values between 0 and 255 for red, green and blue or cyan, magenta, yellow and black color indexes accordingly');
117 | }
118 |
119 | if (is_string($color)) {
120 | if (0 === strpos($color, 'cmyk(')) {
121 | $substrColor = substr($color, 5, strlen($color) - 6);
122 |
123 | $components = array_map(function ($component) {
124 | return round(trim($component, ' %'));
125 | }, explode(',', $substrColor));
126 |
127 | if (count($components) !== 4) {
128 | throw new InvalidArgumentException(sprintf('Unable to parse color %s', $color));
129 | }
130 |
131 | return $components;
132 | } else {
133 | $color = ltrim($color, '#');
134 |
135 | if (strlen($color) !== 3 && strlen($color) !== 6) {
136 | throw new InvalidArgumentException(sprintf('Color must be a hex value in regular (6 characters) or short (3 characters) notation, "%s" given', $color));
137 | }
138 |
139 | if (strlen($color) === 3) {
140 | $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
141 | }
142 |
143 | $color = array_map('hexdec', str_split($color, 2));
144 | }
145 | }
146 |
147 | if (is_int($color)) {
148 | $color = array(255 & ($color >> 16), 255 & ($color >> 8), 255 & $color);
149 | }
150 |
151 | return $color;
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Imagick/Imagine.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Imagick;
13 |
14 | use Imagine\Exception\NotSupportedException;
15 | use Imagine\Image\AbstractImagine;
16 | use Imagine\Image\BoxInterface;
17 | use Imagine\Image\Metadata\MetadataBag;
18 | use Imagine\Image\Palette\Color\ColorInterface;
19 | use Imagine\Exception\InvalidArgumentException;
20 | use Imagine\Exception\RuntimeException;
21 | use Imagine\Image\Palette\CMYK;
22 | use Imagine\Image\Palette\RGB;
23 | use Imagine\Image\Palette\Grayscale;
24 |
25 | /**
26 | * Imagine implementation using the Imagick PHP extension
27 | */
28 | final class Imagine extends AbstractImagine
29 | {
30 | /**
31 | * @throws RuntimeException
32 | */
33 | public function __construct()
34 | {
35 | if (!class_exists('Imagick')) {
36 | throw new RuntimeException('Imagick not installed');
37 | }
38 |
39 | $imagick = new \Imagick();
40 | $v = $imagick->getVersion();
41 | list($version) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
42 |
43 | if (version_compare('6.2.9', $version) > 0) {
44 | throw new RuntimeException('Imagick version 6.2.9 or higher is required');
45 | }
46 | }
47 |
48 | /**
49 | * {@inheritdoc}
50 | */
51 | public function open($path)
52 | {
53 | $handle = @fopen($path, 'r');
54 |
55 | if (false === $handle) {
56 | throw new InvalidArgumentException(sprintf('File %s doesn\'t exist', $path));
57 | }
58 |
59 | fclose($handle);
60 |
61 | try {
62 | $imagick = new \Imagick($path);
63 | $image = new Image($imagick, $this->createPalette($imagick), $this->getMetadataReader()->readFile($path));
64 | } catch (\Exception $e) {
65 | throw new RuntimeException(sprintf('Unable to open image %s', $path), $e->getCode(), $e);
66 | }
67 |
68 | return $image;
69 | }
70 |
71 | /**
72 | * {@inheritdoc}
73 | */
74 | public function create(BoxInterface $size, ColorInterface $color = null)
75 | {
76 | $width = $size->getWidth();
77 | $height = $size->getHeight();
78 |
79 | $palette = null !== $color ? $color->getPalette() : new RGB();
80 | $color = null !== $color ? $color : $palette->color('fff');
81 |
82 | try {
83 | $pixel = new \ImagickPixel((string) $color);
84 | $pixel->setColorValue(\Imagick::COLOR_ALPHA, number_format(round($color->getAlpha() / 100, 2), 1));
85 |
86 | $imagick = new \Imagick();
87 | $imagick->newImage($width, $height, $pixel);
88 | $imagick->setImageMatte(true);
89 | $imagick->setImageBackgroundColor($pixel);
90 |
91 | $pixel->clear();
92 | $pixel->destroy();
93 |
94 | return new Image($imagick, $palette, new MetadataBag());
95 | } catch (\ImagickException $e) {
96 | throw new RuntimeException('Could not create empty image', $e->getCode(), $e);
97 | }
98 | }
99 |
100 | /**
101 | * {@inheritdoc}
102 | */
103 | public function load($string)
104 | {
105 | try {
106 | $imagick = new \Imagick();
107 |
108 | $imagick->readImageBlob($string);
109 | $imagick->setImageMatte(true);
110 |
111 | return new Image($imagick, $this->createPalette($imagick), $this->getMetadataReader()->readData($string));
112 | } catch (\ImagickException $e) {
113 | throw new RuntimeException('Could not load image from string', $e->getCode(), $e);
114 | }
115 | }
116 |
117 | /**
118 | * {@inheritdoc}
119 | */
120 | public function read($resource)
121 | {
122 | if (!is_resource($resource)) {
123 | throw new InvalidArgumentException('Variable does not contain a stream resource');
124 | }
125 |
126 | try {
127 | $imagick = new \Imagick();
128 | $imagick->readImageFile($resource);
129 | } catch (\ImagickException $e) {
130 | throw new RuntimeException('Could not read image from resource', $e->getCode(), $e);
131 | }
132 |
133 | return new Image($imagick, $this->createPalette($imagick), $this->getMetadataReader()->readStream($resource));
134 | }
135 |
136 | /**
137 | * {@inheritdoc}
138 | */
139 | public function font($file, $size, ColorInterface $color)
140 | {
141 | return new Font(new \Imagick(), $file, $size, $color);
142 | }
143 |
144 | private function createPalette(\Imagick $imagick)
145 | {
146 | switch ($imagick->getImageColorspace()) {
147 | case \Imagick::COLORSPACE_RGB:
148 | case \Imagick::COLORSPACE_SRGB:
149 | return new RGB();
150 | case \Imagick::COLORSPACE_CMYK:
151 | return new CMYK();
152 | case \Imagick::COLORSPACE_GRAY:
153 | return new Grayscale();
154 | default:
155 | throw new NotSupportedException('Only RGB and CMYK colorspace are curently supported');
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/ManipulatorInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image;
13 |
14 | use Imagine\Exception\OutOfBoundsException;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 | use Imagine\Image\Fill\FillInterface;
18 |
19 | /**
20 | * The manipulator interface
21 | */
22 | interface ManipulatorInterface
23 | {
24 | const THUMBNAIL_INSET = 'inset';
25 | const THUMBNAIL_OUTBOUND = 'outbound';
26 |
27 | /**
28 | * Copies current source image into a new ImageInterface instance
29 | *
30 | * @throws RuntimeException
31 | *
32 | * @return ManipulatorInterface
33 | */
34 | public function copy();
35 |
36 | /**
37 | * Crops a specified box out of the source image (modifies the source image)
38 | * Returns cropped self
39 | *
40 | * @param PointInterface $start
41 | * @param BoxInterface $size
42 | *
43 | * @throws OutOfBoundsException
44 | * @throws RuntimeException
45 | *
46 | * @return ManipulatorInterface
47 | */
48 | public function crop(PointInterface $start, BoxInterface $size);
49 |
50 | /**
51 | * Resizes current image and returns self
52 | *
53 | * @param BoxInterface $size
54 | * @param string $filter
55 | *
56 | * @throws RuntimeException
57 | *
58 | * @return ManipulatorInterface
59 | */
60 | public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED);
61 |
62 | /**
63 | * Rotates an image at the given angle.
64 | * Optional $background can be used to specify the fill color of the empty
65 | * area of rotated image.
66 | *
67 | * @param integer $angle
68 | * @param ColorInterface $background
69 | *
70 | * @throws RuntimeException
71 | *
72 | * @return ManipulatorInterface
73 | */
74 | public function rotate($angle, ColorInterface $background = null);
75 |
76 | /**
77 | * Pastes an image into a parent image
78 | * Throws exceptions if image exceeds parent image borders or if paste
79 | * operation fails
80 | *
81 | * Returns source image
82 | *
83 | * @param ImageInterface $image
84 | * @param PointInterface $start
85 | *
86 | * @throws InvalidArgumentException
87 | * @throws OutOfBoundsException
88 | * @throws RuntimeException
89 | *
90 | * @return ManipulatorInterface
91 | */
92 | public function paste(ImageInterface $image, PointInterface $start);
93 |
94 | /**
95 | * Saves the image at a specified path, the target file extension is used
96 | * to determine file format, only jpg, jpeg, gif, png, wbmp and xbm are
97 | * supported
98 | *
99 | * @param string $path
100 | * @param array $options
101 | *
102 | * @throws RuntimeException
103 | *
104 | * @return ManipulatorInterface
105 | */
106 | public function save($path = null, array $options = array());
107 |
108 | /**
109 | * Outputs the image content
110 | *
111 | * @param string $format
112 | * @param array $options
113 | *
114 | * @throws RuntimeException
115 | *
116 | * @return ManipulatorInterface
117 | */
118 | public function show($format, array $options = array());
119 |
120 | /**
121 | * Flips current image using horizontal axis
122 | *
123 | * @throws RuntimeException
124 | *
125 | * @return ManipulatorInterface
126 | */
127 | public function flipHorizontally();
128 |
129 | /**
130 | * Flips current image using vertical axis
131 | *
132 | * @throws RuntimeException
133 | *
134 | * @return ManipulatorInterface
135 | */
136 | public function flipVertically();
137 |
138 | /**
139 | * Remove all profiles and comments
140 | *
141 | * @throws RuntimeException
142 | *
143 | * @return ManipulatorInterface
144 | */
145 | public function strip();
146 |
147 | /**
148 | * Generates a thumbnail from a current image
149 | * Returns it as a new image, doesn't modify the current image
150 | *
151 | * @param BoxInterface $size
152 | * @param string $mode
153 | * @param string $filter The filter to use for resizing, one of ImageInterface::FILTER_*
154 | *
155 | * @throws RuntimeException
156 | *
157 | * @return ManipulatorInterface
158 | */
159 | public function thumbnail(BoxInterface $size, $mode = self::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED);
160 |
161 | /**
162 | * Applies a given mask to current image's alpha channel
163 | *
164 | * @param ImageInterface $mask
165 | *
166 | * @return ManipulatorInterface
167 | */
168 | public function applyMask(ImageInterface $mask);
169 |
170 | /**
171 | * Fills image with provided filling, by replacing each pixel's color in
172 | * the current image with corresponding color from FillInterface, and
173 | * returns modified image
174 | *
175 | * @param FillInterface $fill
176 | *
177 | * @return ManipulatorInterface
178 | */
179 | public function fill(FillInterface $fill);
180 | }
181 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/Color/RGB.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette\Color;
13 |
14 | use Imagine\Image\Palette\RGB as RGBPalette;
15 | use Imagine\Exception\InvalidArgumentException;
16 |
17 | final class RGB implements ColorInterface
18 | {
19 | /**
20 | * @var integer
21 | */
22 | private $r;
23 |
24 | /**
25 | * @var integer
26 | */
27 | private $g;
28 |
29 | /**
30 | * @var integer
31 | */
32 | private $b;
33 |
34 | /**
35 | * @var integer
36 | */
37 | private $alpha;
38 |
39 | /**
40 | *
41 | * @var RGBPalette
42 | */
43 | private $palette;
44 |
45 | public function __construct(RGBPalette $palette, array $color, $alpha)
46 | {
47 | $this->palette = $palette;
48 | $this->setColor($color);
49 | $this->setAlpha($alpha);
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function getValue($component)
56 | {
57 | switch ($component) {
58 | case ColorInterface::COLOR_RED:
59 | return $this->getRed();
60 | case ColorInterface::COLOR_GREEN:
61 | return $this->getGreen();
62 | case ColorInterface::COLOR_BLUE:
63 | return $this->getBlue();
64 | default:
65 | throw new InvalidArgumentException(sprintf('Color component %s is not valid', $component));
66 | }
67 | }
68 |
69 | /**
70 | * Returns RED value of the color
71 | *
72 | * @return integer
73 | */
74 | public function getRed()
75 | {
76 | return $this->r;
77 | }
78 |
79 | /**
80 | * Returns GREEN value of the color
81 | *
82 | * @return integer
83 | */
84 | public function getGreen()
85 | {
86 | return $this->g;
87 | }
88 |
89 | /**
90 | * Returns BLUE value of the color
91 | *
92 | * @return integer
93 | */
94 | public function getBlue()
95 | {
96 | return $this->b;
97 | }
98 |
99 | /**
100 | * {@inheritdoc}
101 | */
102 | public function getPalette()
103 | {
104 | return $this->palette;
105 | }
106 |
107 | /**
108 | * {@inheritdoc}
109 | */
110 | public function getAlpha()
111 | {
112 | return $this->alpha;
113 | }
114 |
115 | /**
116 | * {@inheritdoc}
117 | */
118 | public function dissolve($alpha)
119 | {
120 | return $this->palette->color(array($this->r, $this->g, $this->b), $this->alpha + $alpha);
121 | }
122 |
123 | /**
124 | * {@inheritdoc}
125 | */
126 | public function lighten($shade)
127 | {
128 | return $this->palette->color(
129 | array(
130 | min(255, $this->r + $shade),
131 | min(255, $this->g + $shade),
132 | min(255, $this->b + $shade),
133 | ), $this->alpha
134 | );
135 | }
136 |
137 | /**
138 | * {@inheritdoc}
139 | */
140 | public function darken($shade)
141 | {
142 | return $this->palette->color(
143 | array(
144 | max(0, $this->r - $shade),
145 | max(0, $this->g - $shade),
146 | max(0, $this->b - $shade),
147 | ), $this->alpha
148 | );
149 | }
150 |
151 | /**
152 | * {@inheritdoc}
153 | */
154 | public function grayscale()
155 | {
156 | $gray = min(255, round(0.299 * $this->getRed() + 0.114 * $this->getBlue() + 0.587 * $this->getGreen()));
157 |
158 | return $this->palette->color(array($gray, $gray, $gray), $this->alpha);
159 | }
160 |
161 | /**
162 | * {@inheritdoc}
163 | */
164 | public function isOpaque()
165 | {
166 | return 100 === $this->alpha;
167 | }
168 |
169 | /**
170 | * Returns hex representation of the color
171 | *
172 | * @return string
173 | */
174 | public function __toString()
175 | {
176 | return sprintf('#%02x%02x%02x', $this->r, $this->g, $this->b);
177 | }
178 |
179 | /**
180 | * Internal
181 | *
182 | * Performs checks for validity of given alpha value and sets it
183 | *
184 | * @param integer $alpha
185 | *
186 | * @throws InvalidArgumentException
187 | */
188 | private function setAlpha($alpha)
189 | {
190 | if (!is_int($alpha) || $alpha < 0 || $alpha > 100) {
191 | throw new InvalidArgumentException(sprintf('Alpha must be an integer between 0 and 100, %s given', $alpha));
192 | }
193 |
194 | $this->alpha = $alpha;
195 | }
196 |
197 | /**
198 | * Internal
199 | *
200 | * Performs checks for color validity (array of array(R, G, B))
201 | *
202 | * @param array $color
203 | *
204 | * @throws InvalidArgumentException
205 | */
206 | private function setColor(array $color)
207 | {
208 | if (count($color) !== 3) {
209 | throw new InvalidArgumentException('Color argument must look like array(R, G, B), where R, G, B are the integer values between 0 and 255 for red, green and blue color indexes accordingly');
210 | }
211 |
212 | list($this->r, $this->g, $this->b) = array_values($color);
213 | }
214 | }
215 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Image/Palette/Color/CMYK.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Image\Palette\Color;
13 |
14 | use Imagine\Image\Palette\CMYK as CMYKPalette;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Exception\InvalidArgumentException;
17 |
18 | final class CMYK implements ColorInterface
19 | {
20 | /**
21 | * @var integer
22 | */
23 | private $c;
24 |
25 | /**
26 | * @var integer
27 | */
28 | private $m;
29 |
30 | /**
31 | * @var integer
32 | */
33 | private $y;
34 |
35 | /**
36 | * @var integer
37 | */
38 | private $k;
39 |
40 | /**
41 | *
42 | * @var CMYK
43 | */
44 | private $palette;
45 |
46 | public function __construct(CMYKPalette $palette, array $color)
47 | {
48 | $this->palette = $palette;
49 | $this->setColor($color);
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function getValue($component)
56 | {
57 | switch ($component) {
58 | case ColorInterface::COLOR_CYAN:
59 | return $this->getCyan();
60 | case ColorInterface::COLOR_MAGENTA:
61 | return $this->getMagenta();
62 | case ColorInterface::COLOR_YELLOW:
63 | return $this->getYellow();
64 | case ColorInterface::COLOR_KEYLINE:
65 | return $this->getKeyline();
66 | default:
67 | throw new InvalidArgumentException(sprintf('Color component %s is not valid', $component));
68 | }
69 | }
70 |
71 | /**
72 | * Returns Cyan value of the color
73 | *
74 | * @return integer
75 | */
76 | public function getCyan()
77 | {
78 | return $this->c;
79 | }
80 |
81 | /**
82 | * Returns Magenta value of the color
83 | *
84 | * @return integer
85 | */
86 | public function getMagenta()
87 | {
88 | return $this->m;
89 | }
90 |
91 | /**
92 | * Returns Yellow value of the color
93 | *
94 | * @return integer
95 | */
96 | public function getYellow()
97 | {
98 | return $this->y;
99 | }
100 |
101 | /**
102 | * Returns Key value of the color
103 | *
104 | * @return integer
105 | */
106 | public function getKeyline()
107 | {
108 | return $this->k;
109 | }
110 |
111 | /**
112 | * {@inheritdoc}
113 | */
114 | public function getPalette()
115 | {
116 | return $this->palette;
117 | }
118 |
119 | /**
120 | * {@inheritdoc}
121 | */
122 | public function getAlpha()
123 | {
124 | return null;
125 | }
126 |
127 | /**
128 | * {@inheritdoc}
129 | */
130 | public function dissolve($alpha)
131 | {
132 | throw new RuntimeException('CMYK does not support dissolution');
133 | }
134 |
135 | /**
136 | * {@inheritdoc}
137 | */
138 | public function lighten($shade)
139 | {
140 | return $this->palette->color(
141 | array(
142 | $this->c,
143 | $this->m,
144 | $this->y,
145 | max(0, $this->k - $shade),
146 | )
147 | );
148 | }
149 |
150 | /**
151 | * {@inheritdoc}
152 | */
153 | public function darken($shade)
154 | {
155 | return $this->palette->color(
156 | array(
157 | $this->c,
158 | $this->m,
159 | $this->y,
160 | min(100, $this->k + $shade),
161 | )
162 | );
163 | }
164 |
165 | /**
166 | * {@inheritdoc}
167 | */
168 | public function grayscale()
169 | {
170 | $color = array(
171 | $this->c * (1 - $this->k / 100) + $this->k,
172 | $this->m * (1 - $this->k / 100) + $this->k,
173 | $this->y * (1 - $this->k / 100) + $this->k,
174 | );
175 |
176 | $gray = min(100, round(0.299 * $color[0] + 0.587 * $color[1] + 0.114 * $color[2]));
177 |
178 | return $this->palette->color(array($gray, $gray, $gray, $this->k));
179 | }
180 |
181 | /**
182 | * {@inheritdoc}
183 | */
184 | public function isOpaque()
185 | {
186 | return true;
187 | }
188 |
189 | /**
190 | * Returns hex representation of the color
191 | *
192 | * @return string
193 | */
194 | public function __toString()
195 | {
196 | return sprintf('cmyk(%d%%, %d%%, %d%%, %d%%)', $this->c, $this->m, $this->y, $this->k);
197 | }
198 |
199 | /**
200 | * Internal, Performs checks for color validity (an of array(C, M, Y, K))
201 | *
202 | * @param array $color
203 | *
204 | * @throws InvalidArgumentException
205 | */
206 | private function setColor(array $color)
207 | {
208 | if (count($color) !== 4) {
209 | throw new InvalidArgumentException('Color argument must look like array(C, M, Y, K), where C, M, Y, K are the integer values between 0 and 255 for cyan, magenta, yellow and black color indexes accordingly');
210 | }
211 |
212 | $colors = array_values($color);
213 | array_walk($colors, function ($color) {
214 | return max(0, min(100, $color));
215 | });
216 |
217 | list($this->c, $this->m, $this->y, $this->k) = $colors;
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gmagick/Imagine.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gmagick;
13 |
14 | use Imagine\Image\AbstractImagine;
15 | use Imagine\Exception\NotSupportedException;
16 | use Imagine\Image\BoxInterface;
17 | use Imagine\Image\Metadata\MetadataBag;
18 | use Imagine\Image\Palette\Color\ColorInterface;
19 | use Imagine\Image\Palette\Grayscale;
20 | use Imagine\Image\Palette\CMYK;
21 | use Imagine\Image\Palette\RGB;
22 | use Imagine\Image\Palette\Color\CMYK as CMYKColor;
23 | use Imagine\Exception\InvalidArgumentException;
24 | use Imagine\Exception\RuntimeException;
25 |
26 | /**
27 | * Imagine implementation using the Gmagick PHP extension
28 | */
29 | class Imagine extends AbstractImagine
30 | {
31 | /**
32 | * @throws RuntimeException
33 | */
34 | public function __construct()
35 | {
36 | if (!class_exists('Gmagick')) {
37 | throw new RuntimeException('Gmagick not installed');
38 | }
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function open($path)
45 | {
46 | $handle = @fopen($path, 'r');
47 |
48 | if (false === $handle) {
49 | throw new InvalidArgumentException(sprintf('File %s doesn\'t exist', $path));
50 | }
51 |
52 | fclose($handle);
53 |
54 | try {
55 | $gmagick = new \Gmagick($path);
56 | $image = new Image($gmagick, $this->createPalette($gmagick), $this->getMetadataReader()->readFile($path));
57 | } catch (\GmagickException $e) {
58 | throw new RuntimeException(sprintf('Could not open image %s', $path), $e->getCode(), $e);
59 | }
60 |
61 | return $image;
62 | }
63 |
64 | /**
65 | * {@inheritdoc}
66 | */
67 | public function create(BoxInterface $size, ColorInterface $color = null)
68 | {
69 | $width = $size->getWidth();
70 | $height = $size->getHeight();
71 |
72 | $palette = null !== $color ? $color->getPalette() : new RGB();
73 | $color = null !== $color ? $color : $palette->color('fff');
74 |
75 | try {
76 | $gmagick = new \Gmagick();
77 | // Gmagick does not support creation of CMYK GmagickPixel
78 | // see https://bugs.php.net/bug.php?id=64466
79 | if ($color instanceof CMYKColor) {
80 | $switchPalette = $palette;
81 | $palette = new RGB();
82 | $pixel = new \GmagickPixel($palette->color((string) $color));
83 | } else {
84 | $switchPalette = null;
85 | $pixel = new \GmagickPixel((string) $color);
86 | }
87 |
88 | if ($color->getPalette()->supportsAlpha() && $color->getAlpha() < 100) {
89 | throw new NotSupportedException('alpha transparency is not supported');
90 | }
91 |
92 | $gmagick->newimage($width, $height, $pixel->getcolor(false));
93 | $gmagick->setimagecolorspace(\Gmagick::COLORSPACE_TRANSPARENT);
94 | $gmagick->setimagebackgroundcolor($pixel);
95 |
96 | $image = new Image($gmagick, $palette, new MetadataBag());
97 |
98 | if ($switchPalette) {
99 | $image->usePalette($switchPalette);
100 | }
101 |
102 | return $image;
103 | } catch (\GmagickException $e) {
104 | throw new RuntimeException('Could not create empty image', $e->getCode(), $e);
105 | }
106 | }
107 |
108 | /**
109 | * {@inheritdoc}
110 | */
111 | public function load($string)
112 | {
113 | return $this->doLoad($string, $this->getMetadataReader()->readData($string));
114 | }
115 |
116 | /**
117 | * {@inheritdoc}
118 | */
119 | public function read($resource)
120 | {
121 | if (!is_resource($resource)) {
122 | throw new InvalidArgumentException('Variable does not contain a stream resource');
123 | }
124 |
125 | $content = stream_get_contents($resource);
126 |
127 | if (false === $content) {
128 | throw new InvalidArgumentException('Couldn\'t read given resource');
129 | }
130 |
131 | return $this->doLoad($content, $this->getMetadataReader()->readStream($resource));
132 | }
133 |
134 | /**
135 | * {@inheritdoc}
136 | */
137 | public function font($file, $size, ColorInterface $color)
138 | {
139 | $gmagick = new \Gmagick();
140 | $gmagick->newimage(1, 1, 'transparent');
141 |
142 | return new Font($gmagick, $file, $size, $color);
143 | }
144 |
145 | private function createPalette(\Gmagick $gmagick)
146 | {
147 | switch ($gmagick->getimagecolorspace()) {
148 | case \Gmagick::COLORSPACE_SRGB:
149 | case \Gmagick::COLORSPACE_RGB:
150 | return new RGB();
151 | case \Gmagick::COLORSPACE_CMYK:
152 | return new CMYK();
153 | case \Gmagick::COLORSPACE_GRAY:
154 | return new Grayscale();
155 | default:
156 | throw new NotSupportedException('Only RGB and CMYK colorspace are curently supported');
157 | }
158 | }
159 |
160 | private function doLoad($content, MetadataBag $metadata)
161 | {
162 | try {
163 | $gmagick = new \Gmagick();
164 | $gmagick->readimageblob($content);
165 | } catch (\GmagickException $e) {
166 | throw new RuntimeException(
167 | 'Could not load image from string', $e->getCode(), $e
168 | );
169 | }
170 |
171 | return new Image($gmagick, $this->createPalette($gmagick), $metadata);
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Image/RAbstractImage.php:
--------------------------------------------------------------------------------
1 | metadata = $metadata;
22 |
23 | if (is_string($resource)) { // file name
24 | $this->filename = $resource;
25 | if (false === $info = @getimagesize($resource)) {
26 | throw new \Imagine\Exception\RuntimeException("Unable to open image $resource.");
27 | }
28 | $this->size = array($info[0], $info[1]);
29 | $this->format = $info[2];
30 | }
31 | }
32 |
33 |
34 | public function getSize() {
35 | return new Box($this->size[0], $this->size[1]);
36 | }
37 |
38 |
39 | public function getPrescaleSize() {
40 | if (isset($this->prescalesize)) {
41 | return new Box($this->prescalesize[0], $this->prescalesize[1]);
42 | }
43 | else {
44 | return null;
45 | }
46 | }
47 |
48 |
49 | public function getImage() {
50 | if ($this->image === null) { $this->load(); }
51 |
52 | return $this->image;
53 | }
54 |
55 |
56 | public function getFormat() {
57 | return $this->format;
58 | }
59 |
60 |
61 | protected function updateSize() {
62 | $size = $this->image->getSize();
63 | $this->size = array($size->getWidth(), $size->getHeight());
64 | }
65 |
66 |
67 |
68 | /* from ImageInterface */
69 |
70 | public function get($format, array $options = array()) {
71 | return $this->image->get($format, $options);
72 | }
73 |
74 | public function __toString() {
75 | if ($this->image === null) { $this->load(); }
76 |
77 | return (string) $this->image;
78 | }
79 |
80 | public function draw() {
81 | if ($this->image === null) { $this->load(); }
82 |
83 | return $this->image->draw();
84 | }
85 |
86 | public function effects() {
87 | if ($this->image === null) { $this->load(); }
88 |
89 | return $this->image->effects();
90 | }
91 |
92 | public function mask() {
93 | if ($this->image === null) { $this->load(); }
94 |
95 | return $this->image->mask();
96 | }
97 |
98 | public function histogram() {
99 | if ($this->image === null) { $this->load(); }
100 |
101 | return $this->image->histogram;
102 | }
103 |
104 | public function getColorAt(\Imagine\Image\PointInterface $point) {
105 | if ($this->image === null) { $this->load(); }
106 |
107 | return $this->image->getColorAt($point);
108 | }
109 |
110 | public function layers() {
111 | if ($this->image === null) { $this->load(); }
112 |
113 | return $this->image->layers();
114 | }
115 |
116 | public function interlace($scheme) {
117 | if ($this->image === null) { $this->load(); }
118 |
119 | return $this->image->interlace();
120 | }
121 |
122 | public function palette() {
123 | if ($this->image === null) { $this->load(); }
124 |
125 | return $this->image->palette();
126 | }
127 |
128 | public function usePalette(\Imagine\Image\Palette\PaletteInterface $palette) {
129 | if ($this->image === null) { $this->load(); }
130 |
131 | $this->image->usePalette($palette);
132 | return $this;
133 | }
134 |
135 | public function profile(\Imagine\Image\ProfileInterface $profile) {
136 | if ($this->image === null) { $this->load(); }
137 |
138 | $this->image->profile($profile);
139 | return $this;
140 | }
141 |
142 | public function metadata() {
143 | return self::$emptyBag();
144 | }
145 |
146 |
147 |
148 | /* from ManipulatorInterface */
149 |
150 | public function copy() {
151 | if ($this->image === null) { $this->load(); }
152 |
153 | return $this->image->copy();
154 | }
155 |
156 | public function rotate($angle, \Imagine\Image\Palette\Color\ColorInterface $background = null) {
157 | if ($this->image === null) { $this->load(); }
158 |
159 | $this->image->rotate($angle, $background);
160 | $this->updateSize();
161 | return $this;
162 | }
163 |
164 | public function paste(ImageInterface $image, \Imagine\Image\PointInterface $start) {
165 | if ($this->image === null) { $this->load(); }
166 |
167 | $this->image->paste($image, $start);
168 | return $this;
169 | }
170 |
171 | public function save($path = null, array $options = array()) {
172 | if ($this->image === null) { $this->load(); }
173 |
174 | $this->image->save($path, $options);
175 | return $this;
176 | }
177 |
178 | public function show($format, array $options = array()) {
179 | if ($this->image === null) { $this->load(); }
180 |
181 | return $this->image->show($format, $options);
182 | }
183 |
184 | public function flipHorizontally() {
185 | if ($this->image === null) { $this->load(); }
186 |
187 | $this->image->flipHorizontally();
188 | return $this;
189 | }
190 |
191 | public function flipVertically() {
192 | if ($this->image === null) { $this->load(); }
193 |
194 | $this->image->flipVertically();
195 | return $this;
196 | }
197 |
198 | public function strip() {
199 | if ($this->image === null) { $this->load(); }
200 |
201 | $this->image->strip();
202 | return $this;
203 | }
204 |
205 | public function thumbnail(BoxInterface $size, $mode = 'inset', $filter = 'undefined') {
206 | if ($this->image === null) { $this->load(array($size->getWidth(), $size->getHeight())); }
207 |
208 | $this->image = $this->image->thumbnail($size, $mode, $filter);
209 | $this->updateSize();
210 | return $this;
211 | }
212 |
213 | public function applyMask(ImageInterface $mask) {
214 | if ($this->image === null) { $this->load(); }
215 |
216 | $this->image->applyMask($mask);
217 | return $this;
218 | }
219 |
220 | public function fill(\Imagine\Image\Fill\FillInterface $fill) {
221 | if ($this->image === null) { $this->load(); }
222 |
223 | $this->image->fill($fill);
224 | return $this;
225 | }
226 | }
227 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gd/Imagine.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gd;
13 |
14 | use Imagine\Image\AbstractImagine;
15 | use Imagine\Image\Metadata\MetadataBag;
16 | use Imagine\Image\Palette\Color\ColorInterface;
17 | use Imagine\Image\Palette\RGB;
18 | use Imagine\Image\Palette\PaletteInterface;
19 | use Imagine\Image\BoxInterface;
20 | use Imagine\Image\Palette\Color\RGB as RGBColor;
21 | use Imagine\Exception\InvalidArgumentException;
22 | use Imagine\Exception\RuntimeException;
23 |
24 | /**
25 | * Imagine implementation using the GD library
26 | */
27 | final class Imagine extends AbstractImagine
28 | {
29 | /**
30 | * @var array
31 | */
32 | private $info;
33 |
34 | /**
35 | * @throws RuntimeException
36 | */
37 | public function __construct()
38 | {
39 | $this->loadGdInfo();
40 | $this->requireGdVersion('2.0.1');
41 | }
42 |
43 | /**
44 | * {@inheritdoc}
45 | */
46 | public function create(BoxInterface $size, ColorInterface $color = null)
47 | {
48 | $width = $size->getWidth();
49 | $height = $size->getHeight();
50 |
51 | $resource = imagecreatetruecolor($width, $height);
52 |
53 | if (false === $resource) {
54 | throw new RuntimeException('Create operation failed');
55 | }
56 |
57 | $palette = null !== $color ? $color->getPalette() : new RGB();
58 | $color = $color ? $color : $palette->color('fff');
59 |
60 | if (!$color instanceof RGBColor) {
61 | throw new InvalidArgumentException('GD driver only supports RGB colors');
62 | }
63 |
64 | $index = imagecolorallocatealpha($resource, $color->getRed(), $color->getGreen(), $color->getBlue(), round(127 * $color->getAlpha() / 100));
65 |
66 | if (false === $index) {
67 | throw new RuntimeException('Unable to allocate color');
68 | }
69 |
70 | if (false === imagefill($resource, 0, 0, $index)) {
71 | throw new RuntimeException('Could not set background color fill');
72 | }
73 |
74 | if ($color->getAlpha() >= 95) {
75 | imagecolortransparent($resource, $index);
76 | }
77 |
78 | return $this->wrap($resource, $palette, new MetadataBag());
79 | }
80 |
81 | /**
82 | * {@inheritdoc}
83 | */
84 | public function open($path)
85 | {
86 | $data = @file_get_contents($path);
87 |
88 | if (false === $data) {
89 | throw new InvalidArgumentException(sprintf('File %s doesn\'t exist', $path));
90 | }
91 |
92 | $resource = @imagecreatefromstring($data);
93 |
94 | if (!is_resource($resource)) {
95 | throw new InvalidArgumentException(sprintf('Unable to open image %s', $path));
96 | }
97 |
98 | return $this->wrap($resource, new RGB(), $this->getMetadataReader()->readFile($path));
99 | }
100 |
101 | /**
102 | * {@inheritdoc}
103 | */
104 | public function load($string)
105 | {
106 | return $this->doLoad($string, $this->getMetadataReader()->readData($string));
107 | }
108 |
109 | /**
110 | * {@inheritdoc}
111 | */
112 | public function read($resource)
113 | {
114 | if (!is_resource($resource)) {
115 | throw new InvalidArgumentException('Variable does not contain a stream resource');
116 | }
117 |
118 | $content = stream_get_contents($resource);
119 |
120 | if (false === $content) {
121 | throw new InvalidArgumentException('Cannot read resource content');
122 | }
123 |
124 | return $this->doLoad($content, $this->getMetadataReader()->readStream($resource));
125 | }
126 |
127 | /**
128 | * {@inheritdoc}
129 | */
130 | public function font($file, $size, ColorInterface $color)
131 | {
132 | if (!$this->info['FreeType Support']) {
133 | throw new RuntimeException('GD is not compiled with FreeType support');
134 | }
135 |
136 | return new Font($file, $size, $color);
137 | }
138 |
139 | private function wrap($resource, PaletteInterface $palette, MetadataBag $metadata)
140 | {
141 | if (!imageistruecolor($resource)) {
142 | list($width, $height) = array(imagesx($resource), imagesy($resource));
143 |
144 | // create transparent truecolor canvas
145 | $truecolor = imagecreatetruecolor($width, $height);
146 | $transparent = imagecolorallocatealpha($truecolor, 255, 255, 255, 127);
147 |
148 | imagefill($truecolor, 0, 0, $transparent);
149 | imagecolortransparent($truecolor, $transparent);
150 |
151 | imagecopymerge($truecolor, $resource, 0, 0, 0, 0, $width, $height, 100);
152 |
153 | imagedestroy($resource);
154 | $resource = $truecolor;
155 | }
156 |
157 | if (false === imagealphablending($resource, false) || false === imagesavealpha($resource, true)) {
158 | throw new RuntimeException('Could not set alphablending, savealpha and antialias values');
159 | }
160 |
161 | if (function_exists('imageantialias')) {
162 | imageantialias($resource, true);
163 | }
164 |
165 | return new Image($resource, $palette, $metadata);
166 | }
167 |
168 | private function loadGdInfo()
169 | {
170 | if (!function_exists('gd_info')) {
171 | throw new RuntimeException('Gd not installed');
172 | }
173 |
174 | $this->info = gd_info();
175 | }
176 |
177 | private function requireGdVersion($version)
178 | {
179 | if (version_compare(GD_VERSION, $version, '<')) {
180 | throw new RuntimeException(sprintf('GD2 version %s or higher is required', $version));
181 | }
182 | }
183 |
184 | private function doLoad($string, MetadataBag $metadata)
185 | {
186 | $resource = @imagecreatefromstring($string);
187 |
188 | if (!is_resource($resource)) {
189 | throw new InvalidArgumentException('An image could not be created from the given input');
190 | }
191 |
192 | return $this->wrap($resource, new RGB(), $metadata);
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Filter/Transformation.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Filter;
13 |
14 | use Imagine\Exception\InvalidArgumentException;
15 | use Imagine\Filter\Basic\ApplyMask;
16 | use Imagine\Filter\Basic\Copy;
17 | use Imagine\Filter\Basic\Crop;
18 | use Imagine\Filter\Basic\Fill;
19 | use Imagine\Filter\Basic\FlipVertically;
20 | use Imagine\Filter\Basic\FlipHorizontally;
21 | use Imagine\Filter\Basic\Paste;
22 | use Imagine\Filter\Basic\Resize;
23 | use Imagine\Filter\Basic\Rotate;
24 | use Imagine\Filter\Basic\Save;
25 | use Imagine\Filter\Basic\Show;
26 | use Imagine\Filter\Basic\Strip;
27 | use Imagine\Filter\Basic\Thumbnail;
28 | use Imagine\Image\ImageInterface;
29 | use Imagine\Image\ImagineInterface;
30 | use Imagine\Image\BoxInterface;
31 | use Imagine\Image\Palette\Color\ColorInterface;
32 | use Imagine\Image\Fill\FillInterface;
33 | use Imagine\Image\ManipulatorInterface;
34 | use Imagine\Image\PointInterface;
35 |
36 | /**
37 | * A transformation filter
38 | */
39 | final class Transformation implements FilterInterface, ManipulatorInterface
40 | {
41 | /**
42 | * @var array
43 | */
44 | private $filters = array();
45 |
46 | /**
47 | * @var array
48 | */
49 | private $sorted;
50 |
51 | /**
52 | * An ImagineInterface instance.
53 | *
54 | * @var ImagineInterface
55 | */
56 | private $imagine;
57 |
58 | /**
59 | * Class constructor.
60 | *
61 | * @param ImagineInterface $imagine An ImagineInterface instance
62 | */
63 | public function __construct(ImagineInterface $imagine = null)
64 | {
65 | $this->imagine = $imagine;
66 | }
67 |
68 | /**
69 | * Applies a given FilterInterface onto given ImageInterface and returns
70 | * modified ImageInterface
71 | *
72 | * @param ImageInterface $image
73 | * @param FilterInterface $filter
74 | *
75 | * @return ImageInterface
76 | * @throws InvalidArgumentException
77 | */
78 | public function applyFilter(ImageInterface $image, FilterInterface $filter)
79 | {
80 | if ($filter instanceof ImagineAware) {
81 | if ($this->imagine === null) {
82 | throw new InvalidArgumentException(sprintf('In order to use %s pass an Imagine\Image\ImagineInterface instance to Transformation constructor', get_class($filter)));
83 | }
84 | $filter->setImagine($this->imagine);
85 | }
86 |
87 | return $filter->apply($image);
88 | }
89 |
90 | /**
91 | * Returns a list of filters sorted by their priority. Filters with same priority will be returned in the order they were added.
92 | *
93 | * @return array
94 | */
95 | public function getFilters()
96 | {
97 | if (null === $this->sorted) {
98 | ksort($this->filters);
99 | $this->sorted = call_user_func_array('array_merge', $this->filters);
100 | }
101 |
102 | return $this->sorted;
103 | }
104 |
105 | /**
106 | * {@inheritdoc}
107 | */
108 | public function apply(ImageInterface $image)
109 | {
110 | return array_reduce(
111 | $this->getFilters(),
112 | array($this, 'applyFilter'),
113 | $image
114 | );
115 | }
116 |
117 | /**
118 | * {@inheritdoc}
119 | */
120 | public function copy()
121 | {
122 | return $this->add(new Copy());
123 | }
124 |
125 | /**
126 | * {@inheritdoc}
127 | */
128 | public function crop(PointInterface $start, BoxInterface $size)
129 | {
130 | return $this->add(new Crop($start, $size));
131 | }
132 |
133 | /**
134 | * {@inheritdoc}
135 | */
136 | public function flipHorizontally()
137 | {
138 | return $this->add(new FlipHorizontally());
139 | }
140 |
141 | /**
142 | * {@inheritdoc}
143 | */
144 | public function flipVertically()
145 | {
146 | return $this->add(new FlipVertically());
147 | }
148 |
149 | /**
150 | * {@inheritdoc}
151 | */
152 | public function strip()
153 | {
154 | return $this->add(new Strip());
155 | }
156 |
157 | /**
158 | * {@inheritdoc}
159 | */
160 | public function paste(ImageInterface $image, PointInterface $start)
161 | {
162 | return $this->add(new Paste($image, $start));
163 | }
164 |
165 | /**
166 | * {@inheritdoc}
167 | */
168 | public function applyMask(ImageInterface $mask)
169 | {
170 | return $this->add(new ApplyMask($mask));
171 | }
172 |
173 | /**
174 | * {@inheritdoc}
175 | */
176 | public function fill(FillInterface $fill)
177 | {
178 | return $this->add(new Fill($fill));
179 | }
180 |
181 | /**
182 | * {@inheritdoc}
183 | */
184 | public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED)
185 | {
186 | return $this->add(new Resize($size, $filter));
187 | }
188 |
189 | /**
190 | * {@inheritdoc}
191 | */
192 | public function rotate($angle, ColorInterface $background = null)
193 | {
194 | return $this->add(new Rotate($angle, $background));
195 | }
196 |
197 | /**
198 | * {@inheritdoc}
199 | */
200 | public function save($path = null, array $options = array())
201 | {
202 | return $this->add(new Save($path, $options));
203 | }
204 |
205 | /**
206 | * {@inheritdoc}
207 | */
208 | public function show($format, array $options = array())
209 | {
210 | return $this->add(new Show($format, $options));
211 | }
212 |
213 | /**
214 | * {@inheritdoc}
215 | */
216 | public function thumbnail(BoxInterface $size, $mode = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED)
217 | {
218 | return $this->add(new Thumbnail($size, $mode, $filter));
219 | }
220 |
221 | /**
222 | * Registers a given FilterInterface in an internal array of filters for
223 | * later application to an instance of ImageInterface
224 | *
225 | * @param FilterInterface $filter
226 | * @param int $priority
227 | * @return Transformation
228 | */
229 | public function add(FilterInterface $filter, $priority = 0)
230 | {
231 | $this->filters[$priority][] = $filter;
232 | $this->sorted = null;
233 |
234 | return $this;
235 | }
236 | }
237 |
--------------------------------------------------------------------------------
/core/components/resizer/model/vendor/imagine/imagine/lib/Imagine/Gmagick/Layers.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Imagine\Gmagick;
13 |
14 | use Imagine\Image\AbstractLayers;
15 | use Imagine\Exception\RuntimeException;
16 | use Imagine\Exception\NotSupportedException;
17 | use Imagine\Exception\OutOfBoundsException;
18 | use Imagine\Exception\InvalidArgumentException;
19 | use Imagine\Image\Metadata\MetadataBag;
20 | use Imagine\Image\Palette\PaletteInterface;
21 |
22 | class Layers extends AbstractLayers
23 | {
24 | /**
25 | * @var Image
26 | */
27 | private $image;
28 |
29 | /**
30 | * @var \Gmagick
31 | */
32 | private $resource;
33 |
34 | /**
35 | * @var integer
36 | */
37 | private $offset = 0;
38 |
39 | /**
40 | * @var array
41 | */
42 | private $layers = array();
43 |
44 | /**
45 | * @var PaletteInterface
46 | */
47 | private $palette;
48 |
49 | public function __construct(Image $image, PaletteInterface $palette, \Gmagick $resource)
50 | {
51 | $this->image = $image;
52 | $this->resource = $resource;
53 | $this->palette = $palette;
54 | }
55 |
56 | /**
57 | * {@inheritdoc}
58 | */
59 | public function merge()
60 | {
61 | foreach ($this->layers as $offset => $image) {
62 | try {
63 | $this->resource->setimageindex($offset);
64 | $this->resource->setimage($image->getGmagick());
65 | } catch (\GmagickException $e) {
66 | throw new RuntimeException('Failed to substitute layer', $e->getCode(), $e);
67 | }
68 | }
69 | }
70 |
71 | /**
72 | * {@inheritdoc}
73 | */
74 | public function coalesce()
75 | {
76 | throw new NotSupportedException('Gmagick does not support coalescing');
77 | }
78 |
79 | /**
80 | * {@inheritdoc}
81 | */
82 | public function animate($format, $delay, $loops)
83 | {
84 | if ('gif' !== strtolower($format)) {
85 | throw new NotSupportedException('Animated picture is currently only supported on gif');
86 | }
87 |
88 | if (!is_int($loops) || $loops < 0) {
89 | throw new InvalidArgumentException('Loops must be a positive integer.');
90 | }
91 |
92 | if (null !== $delay && (!is_int($delay) || $delay < 0)) {
93 | throw new InvalidArgumentException('Delay must be either null or a positive integer.');
94 | }
95 |
96 | try {
97 | foreach ($this as $offset => $layer) {
98 | $this->resource->setimageindex($offset);
99 | $this->resource->setimageformat($format);
100 |
101 | if (null !== $delay) {
102 | $this->resource->setimagedelay($delay / 10);
103 | }
104 |
105 | $this->resource->setimageiterations($loops);
106 | }
107 | } catch (\GmagickException $e) {
108 | throw new RuntimeException('Failed to animate layers', $e->getCode(), $e);
109 | }
110 |
111 | return $this;
112 | }
113 |
114 | /**
115 | * {@inheritdoc}
116 | */
117 | public function current()
118 | {
119 | return $this->extractAt($this->offset);
120 | }
121 |
122 | /**
123 | * Tries to extract layer at given offset
124 | *
125 | * @param integer $offset
126 | * @return Image
127 | * @throws RuntimeException
128 | */
129 | private function extractAt($offset)
130 | {
131 | if (!isset($this->layers[$offset])) {
132 | try {
133 | $this->resource->setimageindex($offset);
134 | $this->layers[$offset] = new Image($this->resource->getimage(), $this->palette, new MetadataBag());
135 | } catch (\GmagickException $e) {
136 | throw new RuntimeException(sprintf('Failed to extract layer %d', $offset), $e->getCode(), $e);
137 | }
138 | }
139 |
140 | return $this->layers[$offset];
141 | }
142 |
143 | /**
144 | * {@inheritdoc}
145 | */
146 | public function key()
147 | {
148 | return $this->offset;
149 | }
150 |
151 | /**
152 | * {@inheritdoc}
153 | */
154 | public function next()
155 | {
156 | ++$this->offset;
157 | }
158 |
159 | /**
160 | * {@inheritdoc}
161 | */
162 | public function rewind()
163 | {
164 | $this->offset = 0;
165 | }
166 |
167 | /**
168 | * {@inheritdoc}
169 | */
170 | public function valid()
171 | {
172 | return $this->offset < count($this);
173 | }
174 |
175 | /**
176 | * {@inheritdoc}
177 | */
178 | public function count()
179 | {
180 | try {
181 | return $this->resource->getnumberimages();
182 | } catch (\GmagickException $e) {
183 | throw new RuntimeException('Failed to count the number of layers', $e->getCode(), $e);
184 | }
185 | }
186 |
187 | /**
188 | * {@inheritdoc}
189 | */
190 | public function offsetExists($offset)
191 | {
192 | return is_int($offset) && $offset >= 0 && $offset < count($this);
193 | }
194 |
195 | /**
196 | * {@inheritdoc}
197 | */
198 | public function offsetGet($offset)
199 | {
200 | return $this->extractAt($offset);
201 | }
202 |
203 | /**
204 | * {@inheritdoc}
205 | */
206 | public function offsetSet($offset, $image)
207 | {
208 | if (!$image instanceof Image) {
209 | throw new InvalidArgumentException('Only a Gmagick Image can be used as layer');
210 | }
211 |
212 | if (null === $offset) {
213 | $offset = count($this) - 1;
214 | } else {
215 | if (!is_int($offset)) {
216 | throw new InvalidArgumentException('Invalid offset for layer, it must be an integer');
217 | }
218 |
219 | if (count($this) < $offset || 0 > $offset) {
220 | throw new OutOfBoundsException(sprintf('Invalid offset for layer, it must be a value between 0 and %d, %d given', count($this), $offset));
221 | }
222 |
223 | if (isset($this[$offset])) {
224 | unset($this[$offset]);
225 | $offset = $offset - 1;
226 | }
227 | }
228 |
229 | $frame = $image->getGmagick();
230 |
231 | try {
232 | if (count($this) > 0) {
233 | $this->resource->setimageindex($offset);
234 | $this->resource->nextimage();
235 | }
236 | $this->resource->addimage($frame);
237 |
238 | /**
239 | * ugly hack to bypass issue https://bugs.php.net/bug.php?id=64623
240 | */
241 | if (count($this) == 2) {
242 | $this->resource->setimageindex($offset+1);
243 | $this->resource->nextimage();
244 | $this->resource->addimage($frame);
245 | unset($this[0]);
246 | }
247 | } catch (\GmagickException $e) {
248 | throw new RuntimeException('Unable to set the layer', $e->getCode(), $e);
249 | }
250 |
251 | $this->layers = array();
252 | }
253 |
254 | /**
255 | * {@inheritdoc}
256 | */
257 | public function offsetUnset($offset)
258 | {
259 | try {
260 | $this->extractAt($offset);
261 | } catch (RuntimeException $e) {
262 | return;
263 | }
264 |
265 | try {
266 | $this->resource->setimageindex($offset);
267 | $this->resource->removeimage();
268 | } catch (\GmagickException $e) {
269 | throw new RuntimeException('Unable to remove layer', $e->getCode(), $e);
270 | }
271 | }
272 | }
273 |
--------------------------------------------------------------------------------