Файловый менеджер - Редактировать - /home/pimjdymy/public_html/safrandsi/pixelandtonic.zip
Назад
PK yE\��Le e imagine/LICENSEnu �[��� Copyright (c) 2004-2012 Bulat Shakirzyanov Copyright (c) 2016 Pixel & Tonic, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This software embeds Adobe ICC Profiles, see license at http://www.adobe.com/support/downloads/iccprofiles/icc_eula_mac_dist.html . This software also embeds ICC Profile from colormanagement.org. Please find information about their license at http://colormanagement.org/ . PK yE\�y[̝9 �9 imagine/CHANGELOG.mdnu �[��� # CHANGELOG ### 1.3.3 (2022-11-16) * Fix invalid format MIME type definition (#835, @xdanik) ### 1.3.2 (2022-04-01) * Workaround for a bug in PHP 7.3+opcache that causes segmentation faults (#826, #829, #828, @ausi, @mnocon, @mlocati) ### 1.3.1 (2022-03-15) * Fix undefined variable $engineRawVersion in Imagick/Gmagick DriverInfo (#825, @fxbt) ### 1.3.0 (2022-03-15) * Minimum PHP supported version is now 5.5 (#820, @PowerKiKi) * Support AVIF, HEIC, and JXL in Imagick driver (#759, #765, @ausi) * Support AVIF in GD driver (#791, @mlocati) * Make the $filter parameter of the resize method invariant (#776, @mlocati) * Ability to specify the alpha-blending of the GD drawer (#790, @mlocati) * Add support for SINCFAST filter in Imagick driver (#823, @mlocati) * Fix applyMask() for GD driver (#708, @ninze) * Fix PHP 8.1 compatibility (#768, #791, @ausi, @mlocati) * Fix error handling in grayscale() for Gmagick driver (#757, @dmitry-kulikov) * Fix convolve() for Imagick driver (#775, @mlocati) * Fix array retuned by histogram() method of GD and Imagick drivers (#797, @mlocati) * Fix handling alpha channel in Imagick (#775, #798, @mlocati) * New Driver\Info classes to inspect installed drivers (#802, #805, #806, @mlocati) * Fix wrong load logic in Imagick (#807, @mlocati) ### 1.2.4 (2020-11-03) * Fix PHP 8.0 compatibility, except gmagick - see https://bugs.php.net/bug.php?id=80106 (#740, @ausi) * Optimize reading EXIF metadata from local files (#741, @jorrit) * Fix rotation with imagick (#734, @lashus @ausi) * Fix saving multi-layer images (eg animated GIFs) as plain images with gmagick and imagick (#746, @alexander-schranz @mlocati) * Fix gmagick not resolving the correct export format in some edge cases (#750, @ausi) ### 1.2.3 (2019-12-04) * Handle jfif extension in GD driver (#727, @sylvain-msl-talkspirit) * Improve detection of unsupported Exit Metadata Reader (#729, @mlocati, @ausi) ### 1.2.2 (2019-07-09) * The GD driver can now load WebP files (#711, #718, @lashus, @ausi) * Avoid calling `imageantialias` if it's not available (#713, @ahukkanen) ### 1.2.1 (2019-06-03) * Silence call to `\Imagick::setImageOpacity()` in order to prevent deprecation error with Imagick 3.4.4 and ImageMagick 6 (#715, @samdark, @mlocati) ### 1.2.0 (2018-12-07) * `ExifMetadataReader` now returns all the available metadata, not only EXIF and IFD0 (#701, @mlocati) ### 1.1.0 (2018-10-25) * New `ImageInterface::THUMBNAIL_FLAG_NOCLONE` flag for `thumbnail()` to let it modify the original image instance in order to save memory (@mlocati) ### 1.0.2 (2018-10-24) * Check that the Imagick PHP extension is not compiled using ImageMagick version 7.0.7-32 because it does not work correctly (@mlocati) ### 1.0.1 (2018-09-27) * `Box` now rounds the width/height it receives (previously it discarded the decimal points) (@mlocati) ### 1.0.0 (2018-09-25) * New `FontInterface` method: `wrapText` - split a text into multiple lines, so that it fits a specific width (@mlocati) **BREAKING CHANGE** if you have your own `FontInterface` implementation, it now must implement `wrapText` * Drawer methods can now accept a thickness of zero (@mlocati) * Fix drawing unfilled chords with GD driver (@mlocati) * Fix thickness drawing of unfilled chords with Imagick and Gmagick drivers (@mlocati) * Fix handling of radius in `circle` method implementations (@mlocati) * The `dissolve` method of `ColorInterface` normalizes the final value of alpha (@mlocati) **BREAKING CHANGE** `dissolve` doesn't throw a `Imagine\Exception\InvalidArgumentException` anymore ### 1.0.0-alpha2 (2018-09-08) * The `coalesce` method of `LayerInterface` instances now returns the LayerInterface itself (@mlocati) **BREAKING CHANGE** if you have your own `LayerInterface` implementation, it now must return `$this` * The `__toString` method has been added to `ColorInterface` since all its implementations have it (@mlocati) **BREAKING CHANGE** if you have your own `ColorInterface` implementation, it now must implement `__toString` * New Imagick save option: `optimize` if set, the size of animated GIF files is optimized (@mlocati) **NOTE** Imagick requires that the image frames have the same size * The `paste` method now accepts images not fully included in the destination image (@mlocati) **BREAKING CHANGE** the paste method doesn't throw an OutOfBoundsException anymore * Fix handling of PNG compression in Imagick `save` method (@mlocati) * New drawer methods: `rectangle` and `circle` (@mlocati) **BREAKING CHANGE** if you have your own implementation of `DrawerInterface` you should add these two new methods * The `getChannelsMaxValue` method has been added to `PaletteInterface` (@mlocati) **BREAKING CHANGE** if you have your own `PaletteInterface` implementation, it now must implement this new method ### 1.0.0-alpha1 (2018-08-28) * Imagine is now tested under Windows too (@mlocati) * Add support to webp image format (@chregu, @antoligy, @alexander-schranz) * Add `Imagine\File\LoaderInterface` that allows loading remote images with any imaging driver (@mlocati). You can use your own `LoaderInterface` implementation so that you can for instance use curl or any other library. * Fix some phpdoc issues (@mlocati) * `flipHorizontally` and `flipVertically` methods of GD images is now much faster on PHP 5.5+ (@mlocati) * Fix loading of PNG indexed images with GD (@mlocati) * Loading indexed images with GD is now much faster on PHP 5.5+ (@mlocati) * Add support to grayscale images with Gmagick (@mlocati) * Add support to alpha channels of Gmagick images (@mlocati) * Fix `getColorAt` method of Gmagick images (@mlocati) * Add `getTransformations` to the `Autorotate` filter, so that you can get the list of transformations that should be applied to an image accordingly to the EXIF metadata (@mlocati) * The metadata reader now doesn't throw exceptions or warnings (@lentex, @mlocati) * Fix documentation (@ZhangChaoWN, @Mark-H, @mlocati) * Fix pixel range issue with Gmagick image (@b-viguier) * Fix `text` drawer method on Windows when using relative font file paths (@mlocati) * Fix `box` font method on Windows when using relative font file paths (@mlocati) * Fix crash on Windows when loading an image with Imagick (@mlocati) * Fix generation of API documentation (@mlocati) * Add `jpeg_sampling_factors` option when saving JPEG images (Gmagick/Imagick only) (@ausi) * Add BMP as supported image format (@mlocati) * Add support to new image type constants of Imagick (@ausi) * Check that Imagick correctly supports profiles (@ausi) * Add `setMetadataReader`/`getMetadataReader` to `ImagineInterface` (@mlocati) **BREAKING CHANGE** if you have your own `ImagineInterface` implementation, it now must implement those two methods * Fix creating Gmagick images with alpha colors when palette doesn't support alpha (@FractalizeR) * Fix warning about deprecated clone method in copy method of Imagick images (@mlocati) * Fix copy methods of Images (the original image and its new copy are now fully detached) (@mlocati) * It's now possible to use `clone $image` as an alternative to `$image->copy()` (@mlocati) * Add support to custom classes for `BoxInterface`, `MetadataReaderInterface`, `FontInterface`, `LoaderInterface`, `LayersInterface`, `ImageInterface` (@mlocati) **BREAKING CHANGE** if you have your own `ImagineInterface` implementation, it now must implement the methods of `ClassFactoryAwareInterface` * Add support for pasting with alpha for GD and Imagick (@AlloVince, @mlocati) * Downscaling a `Box` until it reaches a dimension less than 1 returns a box with dimension of 1 instead of throwing an exception (@mlocati) **BREAKING CHANGE** if you relied on `Box::scale` throwing an exception in this case * New filters: `BlackWhite`, `BorderDetection`, `Negation`, `Neighborhood` (@rejinka) * Minor optimization of filters based on `OnPixelBased` (@rejinka, @mlocati) * Add flag to `thumbnail` to allow upscaling images (@vlakoff) **BREAKING CHANGE** the `$mode` argument has been renamed to `$settings`, and it's now an integer (but old string values are accepted for backward compatibility). In this case the `ManipulatorInterface` constants `THUMBNAIL_INSET`, `THUMBNAIL_OUTBOUND` were changed from string values to integers. * New filter: `brightness` (@lenybernard, @mlocati) * New filter: `colvolve` available for all graphics libraries except gmagick with version prior to 2.0.1RC2 (@armatronic, @mlocati) * Fix bug in Imagine\Image\Palette\RGB::blend() (@dmolineus, @mlocati) * Autoload was moved from PSR-0 to PSR-4, and code files moved from `/lib/Imagine` to `/src` (@mlocati) ### 0.7.1 (2017-05-16) * Remove Symfony PHPUnit bridge as dependency (@craue) ### 0.7.0 (2017-05-02) * Fix memory usage on metadata reading (@Seldaek) * PHP 7.1 support * Latest Imagemagick compatibility (@jdewit) ### 0.6.3.2 (2016-12-07) * Fixed some artifacts left over from a merge conflict in Imagine\Imagick\Imagine. ### 0.6.3.1 (2016-11-28) * Optimize images for storage when resizing with Imagick * Allow images to be saved with a specific PNG format with Imagick * Preserve palette transparency for 8-bit PNG files when saving with Imagick * Add support for GIF files with variable frame delays * Add support for GIF files with non-infinite loop iterations * Fix compatibility issues with Imagick 7.0 ### 0.6.3 (2015-09-19) * Fix wrong array_merge when calling Transformation::getFilters without filters * Add export-ignore git attribute (@Benoth) * Fix docblocks (@Sm0ke0ut and @norkunas) * Fix animated gif loop length options (@jygaulier) * Multiple tweaks for the repository and travis builds (@localheinz, @vrkansagara and @dunzun) * Fix metadata extraction from streams (@armatronic) * Fix autorotation (@tarleb) * Load exifmetadata reader whenever possible * Add metadata getter ### 0.6.2 (2014-11-11) * Stripping image containing an invalid ICC profile fails * MetadataBag now implements \Countable * Fix wrong array_merge in MetadataBag giving invalid results with HTTP resources (@javaguirre) * Fix Imagick merge strategy (@GrahamCampbell) * Fixed various alpha issues (@RadekDvorak) * Fix Image cloning on HHVM (@RdeWilde) * Fix exception on invalid file using GD driver (@vlakoff). * Fix ImageInterface::getSize on animated GIFs (@sokac) ### 0.6.1 (2014-06-16) * Fix invalid namespace usage (#336 @csanquer). ### 0.6.0 (2014-06-13) * BC break: Colors are now provided through the PaletteInterface. Any call to previous Imagine\Image\Color constructor must be removed and use the palette provided by Imagine\Image\ImageInterface::getPalette to create colors. * BC break : Animated GIF default delay is no longer 800ms but null. This avoids resettings a delay on animated image. * Add support for ICC profiles * Add support for CMYK and grayscale colorspace images. * Add filter argument to ImageInterface::thumbnail method. * Add priority to filters (@Richtermeister). * Add blur effect (@Nokrosis). * Rename "quality" option to "jpeg_quality" and apply it only to JPEG files (@vlakoff). * Add "png_compression_level" option (@vlakoff). * Rename "filters" option to "png_compression_filter" (@vlakoff). * Deprecate `quality` and `filters` ManipulatorInterface::save options, use `jpeg_quality`, `png_compression_level` and `png_compression_filter` instead. * Add support for alpha blending in GD drawer (@salem). * Add width parameter to Drawer::text (@salemgolemugoo). * Add NotSupportedException when a driver does not support an operation (@rouffj). * Add support for metadata. * Fix #158: GD alpha detection + Color::isOpaque are broken. * Fix color extraction for non-RGB palettes. ### 0.5.0 (2013-07-10) * Add `Layers::coalesce`. * Add filter option to `ImageInterface::resize`. * Add sharpen effect. * Add interlace support. * `LayersInterface` now extends `ArrayAccess`, gives support for animated gifs. * Remove Imagick and Gmagick flatten after composite. * Fix pixel opacity reading in `Gmagick::histogram`. * Deprecate pear channel installation. * Deprecate phar installation. ### 0.4.1 (2012-12-13) * Lazy-load GD layers. ### 0.4.0 (2012-12-10) * Add support for image Layers. * Add Colorize effect. * Add documentation for the Grayscale effect. * Port RelativeResize filter from JmikolaImagineBundle. ### 0.3.1 (2012-11-12) * Add Grayscale effect. * `Drawer::text` position fix. ### 0.3.0 (2012-07-28) * Add configurable border thickness to drawer interface and implementations. * Add `ImageInterface`::strip. * Add Canvas filter. * Add resolution option on image saving. * Add Grayscale filter. * Add sami API documentation. * Add compression quality to Gmagick. * Add effects API. * Add method to get pixel at point in Gmagick. * Ensure valid background color in rotations. * Fill lines with color to prevent semi-transparency issues. * Use `Imagick::resizeImage` instead of `Imagick::thumbnailImage` for resizing. * Fix PNG transparency on save ; do not flatten if not necessary. ### 0.2.8 (2011-11-29) * Add support for Travis CI. ### 0.2.7 (2011-11-17) * Use composer for autoloading. ### 0.2.6 (2011-11-09) * Documentation enhancements. ### 0.2.5 (2011-10-29) * Add PEAR support. * Documentation enhancements. ### 0.2.4 (2011-10-17) * Add imagine.phar, phar and rake tasks. * Add `ImagineInterface::read` to read from a stream resource. * Documentation enhancements. * Fix gifs transparency issues. ### 0.2.3 (2011-10-16) * Documentation enhancements. ### 0.2.2 (2011-10-16) * Documentation enhancements. ### 0.2.1 (2011-10-15) * Add `PointInterface::move`. * `BoxInterface::scale` can accept floats. * Set antialias mode for GD images. * Fix png compression. ### 0.2.0 (2011-10-06) * Add `Imagine\Fill\Gradient\Linear::getStart`/`getEnd`. * Add `Imagine\Image\Color::isOpaque`. * Add Gmagick transparency exceptions. * Add support for transparency for gif export. * Add widen/heighten methods for easy scaling to target width/height. * Add functionals tests to unit test thumbnails creation. * Add the ability to use hexadecimal notation for `Imagine\Image\Color` construction. * Implement fast linear gradient for Imagick. * Remove lengthy image histogram comparisons. * Extract `ManipulatorInterface` from `ImageInterface`. * Switch methods to final. * New method `ImageInterface::getColorAt`. * Introduce `ImagineAware` abstract filter class. ### 0.1.5 (2011-05-18) * Fix bug in GD rotate. ### 0.1.4 (2011-03-21) * Add environment check to gracefuly skip test. ### 0.1.3 (2011-03-21) * Improve api docs. * Extract `FontInterface`. ### 0.1.2 (2011-03-21) * Add check for GD. ### 0.1.1 (2011-03-21) * Add rounding and fixed thumbnail logic. ### 0.1.0 (2011-03-14) * First tagged version. PK yE\�u�O O # imagine/src/Exception/Exception.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Exception; /** * Imagine-specific exception. */ interface Exception { } PK yE\� � . imagine/src/Exception/OutOfBoundsException.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Exception; /** * Imagine-specific out of bounds exception. */ class OutOfBoundsException extends \OutOfBoundsException implements Exception { } PK yE\�N�W� � / imagine/src/Exception/NotSupportedException.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Exception; /** * Should be used when a driver does not support an operation. */ class NotSupportedException extends RuntimeException implements Exception { } PK yE\=��i� � * imagine/src/Exception/RuntimeException.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Exception; /** * Imagine-specific runtime exception. */ class RuntimeException extends \RuntimeException implements Exception { } PK yE\�u�� � 2 imagine/src/Exception/InvalidArgumentException.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Exception; /** * Imagine-specific invalid argument exception. */ class InvalidArgumentException extends \InvalidArgumentException implements Exception { } PK yE\x�9 9 2 imagine/src/Factory/ClassFactoryAwareInterface.phpnu �[��� <?php namespace Imagine\Factory; /** * An interface that classes that accepts a class factory should implement. */ interface ClassFactoryAwareInterface { /** * Set the class factory instance to be used. * * @param \Imagine\Factory\ClassFactoryInterface $classFactory * * @return $this */ public function setClassFactory(ClassFactoryInterface $classFactory); /** * Get the class factory instance to be used. * * @return \Imagine\Factory\ClassFactoryInterface */ public function getClassFactory(); } PK yE\x+.�� � - imagine/src/Factory/ClassFactoryInterface.phpnu �[��� <?php namespace Imagine\Factory; use Imagine\Image\Palette\Color\ColorInterface; /** * The interface that class factories must implement. */ interface ClassFactoryInterface { /** * The handle to be used for the GD manipulation library. * * @var string */ const HANDLE_GD = 'gd'; /** * The handle to be used for the Gmagick manipulation library. * * @var string */ const HANDLE_GMAGICK = 'gmagick'; /** * The handle to be used for the Imagick manipulation library. * * @var string */ const HANDLE_IMAGICK = 'imagick'; /** * Create a new instance of a metadata reader. * * @return \Imagine\Image\Metadata\MetadataReaderInterface */ public function createMetadataReader(); /** * Create new BoxInterface instance. * * @param int $width The box width * @param int $height The box height * * @return \Imagine\Image\BoxInterface */ public function createBox($width, $height); /** * Create new FontInterface instance. * * @param string $handle The handle that identifies the manipulation library (one of the HANDLE_... constants, or your own implementation). * @param string $file * @param int $size the font size in points (e.g. 10pt means 10) * @param \Imagine\Image\Palette\Color\ColorInterface $color * * @return \Imagine\Image\FontInterface */ public function createFont($handle, $file, $size, ColorInterface $color); /** * Create a new instance of a file loader. * * @param string|mixed $path * * @return \Imagine\File\LoaderInterface */ public function createFileLoader($path); /** * Crate a new instance of a layers interface. * * @param string $handle The handle that identifies the manipulation library (one of the HANDLE_... constants, or your own implementation). * @param \Imagine\Image\ImageInterface $image * @param mixed|null $initialKey the key of the initially selected layer * * @return \Imagine\Image\LayersInterface */ public function createLayers($handle, \Imagine\Image\ImageInterface $image, $initialKey = null); /** * Create a new ImageInterface instance. * * @param string $handle The handle that identifies the manipulation library (one of the HANDLE_... constants, or your own implementation). * @param mixed $resource * @param \Imagine\Image\Palette\PaletteInterface $palette * @param \Imagine\Image\Metadata\MetadataBag $metadata * * @return \Imagine\Image\ImageInterface */ public function createImage($handle, $resource, \Imagine\Image\Palette\PaletteInterface $palette, \Imagine\Image\Metadata\MetadataBag $metadata); /** * Create a new DrawerInterface instance. * * @param string $handle The handle that identifies the manipulation library (one of the HANDLE_... constants, or your own implementation). * @param mixed $resource * * @return \Imagine\Draw\DrawerInterface */ public function createDrawer($handle, $resource); /** * Create a new EffectsInterface instance. * * @param string $handle The handle that identifies the manipulation library (one of the HANDLE_... constants, or your own implementation). * @param mixed $resource * * @return \Imagine\Effects\EffectsInterface */ public function createEffects($handle, $resource); } PK yE\N�Q�] ] $ imagine/src/Factory/ClassFactory.phpnu �[��� <?php namespace Imagine\Factory; use Imagine\Exception\InvalidArgumentException; use Imagine\Exception\RuntimeException; use Imagine\File\Loader; use Imagine\Image\Box; use Imagine\Image\ImageInterface; use Imagine\Image\Metadata\DefaultMetadataReader; use Imagine\Image\Metadata\ExifMetadataReader; use Imagine\Image\Metadata\MetadataBag; use Imagine\Image\Palette\Color\ColorInterface; use Imagine\Image\Palette\PaletteInterface; /** * The default implementation of Imagine\Factory\ClassFactoryInterface. */ class ClassFactory implements ClassFactoryInterface { /** * @var array|null */ private static $gdInfo; /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createMetadataReader() */ public function createMetadataReader() { return $this->finalize(ExifMetadataReader::isSupported() ? new ExifMetadataReader() : new DefaultMetadataReader()); } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createBox() */ public function createBox($width, $height) { return $this->finalize(new Box($width, $height)); } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createFileLoader() */ public function createFileLoader($path) { return $this->finalize(new Loader($path)); } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createDrawer() */ public function createDrawer($handle, $resource) { switch ($handle) { case self::HANDLE_GD: return $this->finalize(new \Imagine\Gd\Drawer($resource)); case self::HANDLE_GMAGICK: return $this->finalize(new \Imagine\Gmagick\Drawer($resource)); case self::HANDLE_IMAGICK: return $this->finalize(new \Imagine\Imagick\Drawer($resource)); default: throw new InvalidArgumentException(sprintf('Unrecognized handle %s in %s', $handle, __FUNCTION__)); } } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createLayers() */ public function createLayers($handle, ImageInterface $image, $initialKey = null) { switch ($handle) { case self::HANDLE_GD: return $this->finalize(new \Imagine\Gd\Layers($image, $image->palette(), $image->getGdResource(), (int) $initialKey)); case self::HANDLE_GMAGICK: return $this->finalize(new \Imagine\Gmagick\Layers($image, $image->palette(), $image->getGmagick(), (int) $initialKey)); case self::HANDLE_IMAGICK: return $this->finalize(new \Imagine\Imagick\Layers($image, $image->palette(), $image->getImagick(), (int) $initialKey)); default: throw new InvalidArgumentException(sprintf('Unrecognized handle %s in %s', $handle, __FUNCTION__)); } } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createEffects() */ public function createEffects($handle, $resource) { switch ($handle) { case self::HANDLE_GD: return $this->finalize(new \Imagine\Gd\Effects($resource)); case self::HANDLE_GMAGICK: return $this->finalize(new \Imagine\Gmagick\Effects($resource)); case self::HANDLE_IMAGICK: return $this->finalize(new \Imagine\Imagick\Effects($resource)); default: throw new InvalidArgumentException(sprintf('Unrecognized handle %s in %s', $handle, __FUNCTION__)); } } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createImage() */ public function createImage($handle, $resource, PaletteInterface $palette, MetadataBag $metadata) { switch ($handle) { case self::HANDLE_GD: return $this->finalize(new \Imagine\Gd\Image($resource, $palette, $metadata)); case self::HANDLE_GMAGICK: return $this->finalize(new \Imagine\Gmagick\Image($resource, $palette, $metadata)); case self::HANDLE_IMAGICK: return $this->finalize(new \Imagine\Imagick\Image($resource, $palette, $metadata)); default: throw new InvalidArgumentException(sprintf('Unrecognized handle %s in %s', $handle, __FUNCTION__)); } } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryInterface::createFont() */ public function createFont($handle, $file, $size, ColorInterface $color) { switch ($handle) { case self::HANDLE_GD: $gdInfo = static::getGDInfo(); if (!$gdInfo['FreeType Support']) { throw new RuntimeException('GD is not compiled with FreeType support'); } return $this->finalize(new \Imagine\Gd\Font($file, $size, $color)); case self::HANDLE_GMAGICK: $gmagick = new \Gmagick(); $gmagick->newimage(1, 1, 'transparent'); return $this->finalize(new \Imagine\Gmagick\Font($gmagick, $file, $size, $color)); case self::HANDLE_IMAGICK: return $this->finalize(new \Imagine\Imagick\Font(new \Imagick(), $file, $size, $color)); default: throw new InvalidArgumentException(sprintf('Unrecognized handle %s in %s', $handle, __FUNCTION__)); } } /** * Finalize the newly created object. * * @param object $object * * @return object */ protected function finalize($object) { if ($object instanceof ClassFactoryAwareInterface) { $object->setClassFactory($this); } return $object; } /** * @return array */ protected static function getGDInfo() { if (self::$gdInfo === null) { if (!function_exists('gd_info')) { throw new RuntimeException('GD is not installed'); } self::$gdInfo = gd_info(); } return self::$gdInfo; } } PK yE\nY< < # imagine/src/Image/AbstractImage.phpnu �[��� <?php /* * This file is part of the Imagine package. * * (c) Bulat Shakirzyanov <mallluhuct@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Imagine\Image; use Imagine\Exception\InvalidArgumentException; use Imagine\Factory\ClassFactory; use Imagine\Factory\ClassFactoryAwareInterface; use Imagine\Factory\ClassFactoryInterface; abstract class AbstractImage implements ImageInterface, ClassFactoryAwareInterface { /** * @var \Imagine\Image\Metadata\MetadataBag */ protected $metadata; /** * @var \Imagine\Factory\ClassFactoryInterface|null */ private $classFactory; /** * {@inheritdoc} * * @see \Imagine\Image\ManipulatorInterface::thumbnail() */ public function thumbnail(BoxInterface $size, $settings = ImageInterface::THUMBNAIL_INSET, $filter = ImageInterface::FILTER_UNDEFINED) { $settings = $this->checkThumbnailSettings($settings); $mode = $settings & 0xffff; $allowUpscale = (bool) ($settings & ImageInterface::THUMBNAIL_FLAG_UPSCALE); $noClone = (bool) ($settings & ImageInterface::THUMBNAIL_FLAG_NOCLONE); $imageSize = $this->getSize(); $palette = $this->palette(); $thumbnail = $noClone ? $this : $this->copy(); $thumbnail->usePalette($palette); $thumbnail->strip(); if ($size->getWidth() === $imageSize->getWidth() && $size->getHeight() === $imageSize->getHeight()) { // The thumbnail size is the same as the wanted size. return $thumbnail; } if (!$allowUpscale && $size->contains($imageSize)) { // Thumbnail is smaller than the image and we are not upscaling return $thumbnail; } $ratios = array( $size->getWidth() / $imageSize->getWidth(), $size->getHeight() / $imageSize->getHeight(), ); switch ($mode) { case ImageInterface::THUMBNAIL_OUTBOUND: // Crop the image so that it fits the wanted size $ratio = max($ratios); if ($imageSize->contains($size)) { // Downscale the image $imageSize = $imageSize->scale($ratio); $thumbnail->resize($imageSize, $filter); $thumbnailSize = $size; } else { if ($allowUpscale) { // Upscale the image so that the max dimension will be the wanted one $imageSize = $imageSize->scale($ratio); $thumbnail->resize($imageSize, $filter); } $thumbnailSize = new Box( min($imageSize->getWidth(), $size->getWidth()), min($imageSize->getHeight(), $size->getHeight()) ); } $thumbnail->crop( new Point( max(0, round(($imageSize->getWidth() - $size->getWidth()) / 2)), max(0, round(($imageSize->getHeight() - $size->getHeight()) / 2)) ), $thumbnailSize ); break; case ImageInterface::THUMBNAIL_INSET: default: // Scale the image so that it fits the wanted size $ratio = min($ratios); $thumbnailSize = $imageSize->scale($ratio); $thumbnail->resize($thumbnailSize, $filter); break; } return $thumbnail; } /** * Check the settings argument in thumbnail() method. * * @param int $settings */ private function checkThumbnailSettings($settings) { // Preserve BC until version 1.0 if (is_string($settings)) { if ($settings === 'inset') { $settings = ImageInterface::THUMBNAIL_INSET; } elseif ($settings === 'outbound') { $settings = ImageInterface::THUMBNAIL_OUTBOUND; } elseif (is_numeric($settings)) { $settings = (int) $settings; } } if (!is_int($settings)) { throw new InvalidArgumentException('Invalid setting specified'); } $mode = $settings & 0xffff; if ($mode === 0) { $settings |= ImageInterface::THUMBNAIL_INSET; } else { if (!in_array($mode, $this->getAllThumbnailModes())) { if (strlen(str_replace('0', '', decbin($mode))) === 1) { throw new InvalidArgumentException('Invalid setting specified'); } throw new InvalidArgumentException('Only one mode should be specified'); } } return $settings; } /** * Get all the available thumbnail modes. * * @return int[] */ protected function getAllThumbnailModes() { return array( ImageInterface::THUMBNAIL_INSET, ImageInterface::THUMBNAIL_OUTBOUND, ); } /** * Updates a given array of save options for backward compatibility with legacy names. * * @param array $options * * @return array */ protected function updateSaveOptions(array $options) { // Preserve BC until version 1.0 if (isset($options['quality']) && !isset($options['jpeg_quality'])) { $options['jpeg_quality'] = $options['quality']; } return $options; } /** * Get all the available filter defined in ImageInterface. * * @return string[] */ protected static function getAllFilterValues() { static $result; if (!is_array($result)) { $values = array(); $interface = new \ReflectionClass('Imagine\Image\ImageInterface'); foreach ($interface->getConstants() as $name => $value) { if (strpos($name, 'FILTER_') === 0) { $values[] = $value; } } $result = $values; } return $result; } /** * {@inheritdoc} * * @see \Imagine\Image\ImageInterface::metadata() */ public function metadata() { return $this->metadata; } /** * Clones all the resources associated to this instance. */ public function __clone() { if ($this->metadata !== null) { $this->metadata = clone $this->metadata; } } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryAwareInterface::getClassFactory() */ public function getClassFactory() { if ($this->classFactory === null) { $this->classFactory = new ClassFactory(); } return $this->classFactory; } /** * {@inheritdoc} * * @see \Imagine\Factory\ClassFactoryAwareInterface::setClassFactory() */ public function setClassFactory(ClassFactoryInterface $classFactory) { $this->classFactory = $classFactory; return $this; } } PK yE\� �� "