Файловый менеджер - Редактировать - /home/lmsyaran/public_html/pusher/image.tar
Назад
LICENSE 0000644 00000042630 15117027003 0005552 0 ustar 00 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. src/Filter/Backgroundfill.php 0000644 00000006646 15117027003 0012227 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use InvalidArgumentException; use Joomla\Image\ImageFilter; /** * Image Filter class fill background with color; * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Backgroundfill extends ImageFilter { /** * Method to apply a background color to an image resource. * * @param array $options An array of options for the filter. * color Background matte color * * @return void * * @since 1.0 * @throws InvalidArgumentException */ public function execute(array $options = array()) { // Validate that the color value exists and is an integer. if (!isset($options['color'])) { throw new InvalidArgumentException('No color value was given. Expected string or array.'); } $colorCode = (!empty($options['color'])) ? $options['color'] : null; // Get resource dimensions $width = imagesx($this->handle); $height = imagesy($this->handle); // Sanitize color $rgba = $this->sanitizeColor($colorCode); // Enforce alpha on source image if (imageistruecolor($this->handle)) { imagealphablending($this->handle, false); imagesavealpha($this->handle, true); } // Create background $bg = imagecreatetruecolor($width, $height); imagesavealpha($bg, empty($rgba['alpha'])); // Allocate background color. $color = imagecolorallocatealpha($bg, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']); // Fill background imagefill($bg, 0, 0, $color); // Apply image over background imagecopy($bg, $this->handle, 0, 0, 0, 0, $width, $height); // Move flattened result onto curent handle. // If handle was palette-based, it'll stay like that. imagecopy($this->handle, $bg, 0, 0, 0, 0, $width, $height); // Free up memory imagedestroy($bg); } /** * Method to sanitize color values * and/or convert to an array * * @param mixed $input Associative array of colors and alpha, * or hex RGBA string when alpha FF is opaque. * Defaults to black and opaque alpha * * @return array Associative array of red, green, blue and alpha * * @since 1.0 * * @note '#FF0000FF' returns an array with alpha of 0 (opaque) */ protected function sanitizeColor($input) { // Construct default values $colors = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); // Make sure all values are in if (\is_array($input)) { $colors = array_merge($colors, $input); } elseif (\is_string($input)) { // Convert RGBA 6-9 char string $hex = ltrim($input, '#'); $hexValues = array( 'red' => substr($hex, 0, 2), 'green' => substr($hex, 2, 2), 'blue' => substr($hex, 4, 2), 'alpha' => substr($hex, 6, 2), ); $colors = array_map('hexdec', $hexValues); // Convert Alpha to 0..127 when provided if (\strlen($hex) > 6) { $colors['alpha'] = floor((255 - $colors['alpha']) / 2); } } else { // Cannot sanitize such type return $colors; } // Make sure each value is within the allowed range foreach ($colors as &$value) { $value = max(0, min(255, (int) $value)); } $colors['alpha'] = min(127, $colors['alpha']); return $colors; } } src/Filter/Brightness.php 0000644 00000002207 15117027003 0011376 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use InvalidArgumentException; use Joomla\Image\ImageFilter; /** * Image Filter class adjust the brightness of an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Brightness extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 * @throws InvalidArgumentException */ public function execute(array $options = array()) { // Validate that the brightness value exists and is an integer. if (!isset($options[IMG_FILTER_BRIGHTNESS]) || !\is_int($options[IMG_FILTER_BRIGHTNESS])) { throw new InvalidArgumentException('No valid brightness value was given. Expected integer.'); } // Perform the brightness filter. imagefilter($this->handle, IMG_FILTER_BRIGHTNESS, $options[IMG_FILTER_BRIGHTNESS]); } } src/Filter/Contrast.php 0000644 00000002165 15117027003 0011066 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use InvalidArgumentException; use Joomla\Image\ImageFilter; /** * Image Filter class adjust the contrast of an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Contrast extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 * @throws InvalidArgumentException */ public function execute(array $options = array()) { // Validate that the contrast value exists and is an integer. if (!isset($options[IMG_FILTER_CONTRAST]) || !\is_int($options[IMG_FILTER_CONTRAST])) { throw new InvalidArgumentException('No valid contrast value was given. Expected integer.'); } // Perform the contrast filter. imagefilter($this->handle, IMG_FILTER_CONTRAST, $options[IMG_FILTER_CONTRAST]); } } src/Filter/Edgedetect.php 0000644 00000001444 15117027003 0011325 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use Joomla\Image\ImageFilter; /** * Image Filter class to add an edge detect effect to an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Edgedetect extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ public function execute(array $options = array()) { // Perform the edge detection filter. imagefilter($this->handle, IMG_FILTER_EDGEDETECT); } } src/Filter/Emboss.php 0000644 00000001376 15117027003 0010524 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use Joomla\Image\ImageFilter; /** * Image Filter class to emboss an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Emboss extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ public function execute(array $options = array()) { // Perform the emboss filter. imagefilter($this->handle, IMG_FILTER_EMBOSS); } } src/Filter/Grayscale.php 0000644 00000001427 15117027003 0011203 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use Joomla\Image\ImageFilter; /** * Image Filter class to transform an image to grayscale. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Grayscale extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ public function execute(array $options = array()) { // Perform the grayscale filter. imagefilter($this->handle, IMG_FILTER_GRAYSCALE); } } src/Filter/Negate.php 0000644 00000001416 15117027003 0010472 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use Joomla\Image\ImageFilter; /** * Image Filter class to negate the colors of an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Negate extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ public function execute(array $options = array()) { // Perform the negative filter. imagefilter($this->handle, IMG_FILTER_NEGATE); } } src/Filter/Sketchy.php 0000644 00000001425 15117027004 0010702 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use Joomla\Image\ImageFilter; /** * Image Filter class to make an image appear "sketchy". * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Sketchy extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ public function execute(array $options = array()) { // Perform the sketchy filter. imagefilter($this->handle, IMG_FILTER_MEAN_REMOVAL); } } src/Filter/Smooth.php 0000644 00000002160 15117027004 0010536 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image\Filter; use InvalidArgumentException; use Joomla\Image\ImageFilter; /** * Image Filter class adjust the smoothness of an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Smooth extends ImageFilter { /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 * @throws InvalidArgumentException */ public function execute(array $options = array()) { // Validate that the smoothing value exists and is an integer. if (!isset($options[IMG_FILTER_SMOOTH]) || !\is_int($options[IMG_FILTER_SMOOTH])) { throw new InvalidArgumentException('No valid smoothing value was given. Expected integer.'); } // Perform the smoothing filter. imagefilter($this->handle, IMG_FILTER_SMOOTH, $options[IMG_FILTER_SMOOTH]); } } src/Image.php 0000644 00000076050 15117027004 0007073 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; /** * Class to manipulate an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ class Image implements LoggerAwareInterface { /** * @const integer * @since 1.0 */ const SCALE_FILL = 1; /** * @const integer * @since 1.0 */ const SCALE_INSIDE = 2; /** * @const integer * @since 1.0 */ const SCALE_OUTSIDE = 3; /** * @const integer * @since 1.0 */ const CROP = 4; /** * @const integer * @since 1.0 */ const CROP_RESIZE = 5; /** * @const integer * @since 1.0 */ const SCALE_FIT = 6; /** * @const string * @since 1.2.0 */ const ORIENTATION_LANDSCAPE = 'landscape'; /** * @const string * @since 1.2.0 */ const ORIENTATION_PORTRAIT = 'portrait'; /** * @const string * @since 1.2.0 */ const ORIENTATION_SQUARE = 'square'; /** * @var resource|\GdImage The image resource handle. * @since 1.0 */ protected $handle; /** * @var string The source image path. * @since 1.0 */ protected $path; /** * @var array Whether or not different image formats are supported. * @since 1.0 */ protected static $formats = array(); /** * @var LoggerInterface Logger object * @since 1.0 */ protected $logger; /** * @var boolean Flag if an image should use the best quality available. Disable for improved performance. * @since 1.4.0 */ protected $generateBestQuality = true; /** * Class constructor. * * @param mixed $source Either a file path for a source image or a GD resource handler for an image. * * @since 1.0 * @throws \RuntimeException */ public function __construct($source = null) { // Verify that GD support for PHP is available. if (!\extension_loaded('gd')) { // @codeCoverageIgnoreStart throw new \RuntimeException('The GD extension for PHP is not available.'); // @codeCoverageIgnoreEnd } // Determine which image types are supported by GD, but only once. if (!isset(static::$formats[IMAGETYPE_JPEG])) { $info = gd_info(); static::$formats[IMAGETYPE_JPEG] = ($info['JPEG Support']) ? true : false; static::$formats[IMAGETYPE_PNG] = ($info['PNG Support']) ? true : false; static::$formats[IMAGETYPE_GIF] = ($info['GIF Read Support']) ? true : false; } // If the source input is a resource, set it as the image handle. if ($this->isValidImage($source)) { $this->handle = &$source; } elseif (!empty($source) && \is_string($source)) { // If the source input is not empty, assume it is a path and populate the image handle. $this->loadFile($source); } } /** * Get the image resource handle * * @return resource * * @since 1.3.0 * @throws \LogicException if an image has not been loaded into the instance */ public function getHandle() { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } return $this->handle; } /** * Get the logger. * * @return LoggerInterface * * @since 1.0 */ public function getLogger() { // If a logger hasn't been set, use NullLogger if (! ($this->logger instanceof LoggerInterface)) { $this->logger = new NullLogger; } return $this->logger; } /** * Sets a logger instance on the object * * @param LoggerInterface $logger A PSR-3 compliant logger. * * @return Image This object for message chaining. * * @since 1.0 */ public function setLogger(LoggerInterface $logger) { $this->logger = $logger; return $this; } /** * Method to return a properties object for an image given a filesystem path. * * The result object has values for image width, height, type, attributes, mime type, bits, and channels. * * @param string $path The filesystem path to the image for which to get properties. * * @return \stdClass * * @since 1.0 * @throws \InvalidArgumentException * @throws \RuntimeException */ public static function getImageFileProperties($path) { // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image file information. $info = getimagesize($path); if (!$info) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to get properties for the image.'); // @codeCoverageIgnoreEnd } // Build the response object. $properties = (object) array( 'width' => $info[0], 'height' => $info[1], 'type' => $info[2], 'attributes' => $info[3], 'bits' => isset($info['bits']) ? $info['bits'] : null, 'channels' => isset($info['channels']) ? $info['channels'] : null, 'mime' => $info['mime'], 'filesize' => filesize($path), 'orientation' => self::getOrientationString((int) $info[0], (int) $info[1]), ); return $properties; } /** * Method to detect whether an image's orientation is landscape, portrait or square. * * The orientation will be returned as a string. * * @return mixed Orientation string or null. * * @since 1.2.0 */ public function getOrientation() { if ($this->isLoaded()) { return self::getOrientationString($this->getWidth(), $this->getHeight()); } } /** * Compare width and height integers to determine image orientation. * * @param integer $width The width value to use for calculation * @param integer $height The height value to use for calculation * * @return string Orientation string * * @since 1.2.0 */ private static function getOrientationString($width, $height) { switch (true) { case $width > $height : return self::ORIENTATION_LANDSCAPE; case $width < $height : return self::ORIENTATION_PORTRAIT; default: return self::ORIENTATION_SQUARE; } } /** * Method to generate thumbnails from the current image. It allows * creation by resizing or cropping the original image. * * @param mixed $thumbSizes String or array of strings. Example: $thumbSizes = array('150x75','250x150'); * @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping | 5 resize then crop * * @return array * * @since 1.0 * @throws \LogicException * @throws \InvalidArgumentException */ public function generateThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } // Accept a single thumbsize string as parameter if (!\is_array($thumbSizes)) { $thumbSizes = array($thumbSizes); } // Process thumbs $generated = array(); if (!empty($thumbSizes)) { foreach ($thumbSizes as $thumbSize) { // Desired thumbnail size $size = explode('x', strtolower($thumbSize)); if (\count($size) != 2) { throw new \InvalidArgumentException('Invalid thumb size received: ' . $thumbSize); } $thumbWidth = $size[0]; $thumbHeight = $size[1]; switch ($creationMethod) { // Crop case self::CROP: $thumb = $this->crop($thumbWidth, $thumbHeight, null, null, true); break; // Crop-resize case self::CROP_RESIZE: $thumb = $this->cropResize($thumbWidth, $thumbHeight, true); break; default: $thumb = $this->resize($thumbWidth, $thumbHeight, true, $creationMethod); break; } // Store the thumb in the results array $generated[] = $thumb; } } return $generated; } /** * Method to create thumbnails from the current image and save them to disk. It allows creation by resizing * or cropping the original image. * * @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = array('150x75','250x150'); * @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping * @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder * * @return array * * @since 1.0 * @throws \LogicException * @throws \InvalidArgumentException */ public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } // No thumbFolder set -> we will create a thumbs folder in the current image folder if ($thumbsFolder === null) { $thumbsFolder = \dirname($this->getPath()) . '/thumbs'; } // Check destination if (!is_dir($thumbsFolder) && (!is_dir(\dirname($thumbsFolder)) || !@mkdir($thumbsFolder))) { throw new \InvalidArgumentException('Folder does not exist and cannot be created: ' . $thumbsFolder); } // Process thumbs $thumbsCreated = array(); if ($thumbs = $this->generateThumbs($thumbSizes, $creationMethod)) { // Parent image properties $imgProperties = static::getImageFileProperties($this->getPath()); foreach ($thumbs as $thumb) { // Get thumb properties $thumbWidth = $thumb->getWidth(); $thumbHeight = $thumb->getHeight(); // Generate thumb name $filename = pathinfo($this->getPath(), PATHINFO_FILENAME); $fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION); $thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension; // Save thumb file to disk $thumbFileName = $thumbsFolder . '/' . $thumbFileName; if ($thumb->toFile($thumbFileName, $imgProperties->type)) { // Return Image object with thumb path to ease further manipulation $thumb->path = $thumbFileName; $thumbsCreated[] = $thumb; } } } return $thumbsCreated; } /** * Method to crop the current image. * * @param mixed $width The width of the image section to crop in pixels or a percentage. * @param mixed $height The height of the image section to crop in pixels or a percentage. * @param integer $left The number of pixels from the left to start cropping. * @param integer $top The number of pixels from the top to start cropping. * @param boolean $createNew If true the current image will be cloned, cropped and returned; else * the current image will be cropped and returned. * * @return Image * * @since 1.0 * @throws \LogicException */ public function crop($width, $height, $left = null, $top = null, $createNew = true) { // Sanitize width. $width = $this->sanitizeWidth($width, $height); // Sanitize height. $height = $this->sanitizeHeight($height, $width); // Autocrop offsets if ($left === null) { $left = round(($this->getWidth() - $width) / 2); } if ($top === null) { $top = round(($this->getHeight() - $height) / 2); } // Sanitize left. $left = $this->sanitizeOffset($left); // Sanitize top. $top = $this->sanitizeOffset($top); // Create the new truecolor image handle. $handle = imagecreatetruecolor($width, $height); // Allow transparency for the new image handle. imagealphablending($handle, false); imagesavealpha($handle, true); if ($this->isTransparent()) { // Get the transparent color values for the current image. $rgba = imagecolorsforindex($this->getHandle(), imagecolortransparent($this->getHandle())); $color = imagecolorallocatealpha($handle, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']); // Set the transparent color values for the new image. imagecolortransparent($handle, $color); imagefill($handle, 0, 0, $color); } if (!$this->generateBestQuality) { imagecopyresized($handle, $this->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height); } else { imagecopyresampled($handle, $this->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height); } // If we are cropping to a new image, create a new Image object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Swap out the current handle for the new image handle. $this->destroy(); $this->handle = $handle; return $this; } /** * Method to apply a filter to the image by type. Two examples are: grayscale and sketchy. * * @param string $type The name of the image filter to apply. * @param array $options An array of options for the filter. * * @return Image * * @since 1.0 * @see Joomla\Image\Filter * @throws \LogicException */ public function filter($type, array $options = array()) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } // Get the image filter instance. $filter = $this->getFilterInstance($type); // Execute the image filter. $filter->execute($options); return $this; } /** * Method to get the height of the image in pixels. * * @return integer * * @since 1.0 * @throws \LogicException */ public function getHeight() { return imagesy($this->getHandle()); } /** * Method to get the width of the image in pixels. * * @return integer * * @since 1.0 * @throws \LogicException */ public function getWidth() { return imagesx($this->getHandle()); } /** * Method to return the path * * @return string * * @since 1.0 */ public function getPath() { return $this->path; } /** * Method to determine whether or not an image has been loaded into the object. * * @return boolean * * @since 1.0 */ public function isLoaded() { // Make sure the resource handle is valid. return $this->isValidImage($this->handle); } /** * Method to determine whether or not the image has transparency. * * @return boolean * * @since 1.0 * @throws \LogicException */ public function isTransparent() { return imagecolortransparent($this->getHandle()) >= 0; } /** * Method to load a file into the Image object as the resource. * * @param string $path The filesystem path to load as an image. * * @return void * * @since 1.0 * @throws \InvalidArgumentException * @throws \RuntimeException */ public function loadFile($path) { // Destroy the current image handle if it exists $this->destroy(); // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image properties. $properties = static::getImageFileProperties($path); // Attempt to load the image based on the MIME-Type switch ($properties->mime) { case 'image/gif': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_GIF])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type GIF.'); throw new \RuntimeException('Attempting to load an image of unsupported type GIF.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromgif($path); if (!$this->isValidImage($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process GIF image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/jpeg': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_JPEG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type JPG.'); throw new \RuntimeException('Attempting to load an image of unsupported type JPG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromjpeg($path); if (!$this->isValidImage($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process JPG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/png': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_PNG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type PNG.'); throw new \RuntimeException('Attempting to load an image of unsupported type PNG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefrompng($path); if (!$this->isValidImage($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process PNG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; default: $this->getLogger()->error('Attempting to load an image of unsupported type ' . $properties->mime); throw new \InvalidArgumentException('Attempting to load an image of unsupported type ' . $properties->mime); } // Set the filesystem path to the source image. $this->path = $path; } /** * Method to resize the current image. * * @param mixed $width The width of the resized image in pixels or a percentage. * @param mixed $height The height of the resized image in pixels or a percentage. * @param boolean $createNew If true the current image will be cloned, resized and returned; else * the current image will be resized and returned. * @param integer $scaleMethod Which method to use for scaling * * @return Image * * @since 1.0 * @throws \LogicException */ public function resize($width, $height, $createNew = true, $scaleMethod = self::SCALE_INSIDE) { // Sanitize width. $width = $this->sanitizeWidth($width, $height); // Sanitize height. $height = $this->sanitizeHeight($height, $width); // Prepare the dimensions for the resize operation. $dimensions = $this->prepareDimensions($width, $height, $scaleMethod); // Instantiate offset. $offset = new \stdClass; $offset->x = $offset->y = 0; // Center image if needed and create the new truecolor image handle. if ($scaleMethod == self::SCALE_FIT) { // Get the offsets $offset->x = round(($width - $dimensions->width) / 2); $offset->y = round(($height - $dimensions->height) / 2); $handle = imagecreatetruecolor($width, $height); // Make image transparent, otherwise canvas outside initial image would default to black if (!$this->isTransparent()) { $transparency = imagecolorallocatealpha($this->getHandle(), 0, 0, 0, 127); imagecolortransparent($this->getHandle(), $transparency); } } else { $handle = imagecreatetruecolor($dimensions->width, $dimensions->height); } // Allow transparency for the new image handle. imagealphablending($handle, false); imagesavealpha($handle, true); if ($this->isTransparent()) { // Get the transparent color values for the current image. $rgba = imagecolorsforindex($this->getHandle(), imagecolortransparent($this->getHandle())); $color = imagecolorallocatealpha($handle, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']); // Set the transparent color values for the new image. imagecolortransparent($handle, $color); imagefill($handle, 0, 0, $color); } if (!$this->generateBestQuality) { imagecopyresized( $handle, $this->getHandle(), $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight() ); } else { // Use resampling for better quality imagecopyresampled( $handle, $this->getHandle(), $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight() ); } // If we are resizing to a new image, create a new JImage object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Swap out the current handle for the new image handle. $this->destroy(); $this->handle = $handle; return $this; } /** * Method to crop an image after resizing it to maintain * proportions without having to do all the set up work. * * @param integer $width The desired width of the image in pixels or a percentage. * @param integer $height The desired height of the image in pixels or a percentage. * @param integer $createNew If true the current image will be cloned, resized, cropped and returned. * * @return Image * * @since 1.0 */ public function cropResize($width, $height, $createNew = true) { $width = $this->sanitizeWidth($width, $height); $height = $this->sanitizeHeight($height, $width); $resizewidth = $width; $resizeheight = $height; if (($this->getWidth() / $width) < ($this->getHeight() / $height)) { $resizeheight = 0; } else { $resizewidth = 0; } return $this->resize($resizewidth, $resizeheight, $createNew)->crop($width, $height, null, null, false); } /** * Method to rotate the current image. * * @param mixed $angle The angle of rotation for the image * @param integer $background The background color to use when areas are added due to rotation * @param boolean $createNew If true the current image will be cloned, rotated and returned; else * the current image will be rotated and returned. * * @return Image * * @since 1.0 * @throws \LogicException */ public function rotate($angle, $background = -1, $createNew = true) { // Sanitize input $angle = (float) $angle; // Create the new truecolor image handle. $handle = imagecreatetruecolor($this->getWidth(), $this->getHeight()); // Make background transparent if no external background color is provided. if ($background == -1) { // Allow transparency for the new image handle. imagealphablending($handle, false); imagesavealpha($handle, true); $background = imagecolorallocatealpha($handle, 0, 0, 0, 127); } // Copy the image imagecopy($handle, $this->getHandle(), 0, 0, 0, 0, $this->getWidth(), $this->getHeight()); // Rotate the image $handle = imagerotate($handle, $angle, $background); // If we are resizing to a new image, create a new Image object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Swap out the current handle for the new image handle. $this->destroy(); $this->handle = $handle; return $this; } /** * Method to flip the current image. * * @param integer $mode The flip mode for flipping the image {@link https://www.php.net/imageflip#refsect1-function.imageflip-parameters} * @param boolean $createNew If true the current image will be cloned, flipped and returned; else * the current image will be flipped and returned. * * @return Image * * @since 1.2.0 * @throws \LogicException */ public function flip($mode, $createNew = true) { // Create the new truecolor image handle. $handle = imagecreatetruecolor($this->getWidth(), $this->getHeight()); // Copy the image imagecopy($handle, $this->getHandle(), 0, 0, 0, 0, $this->getWidth(), $this->getHeight()); // Flip the image if (!imageflip($handle, $mode)) { throw new \LogicException('Unable to flip the image.'); } // If we are resizing to a new image, create a new Image object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Free the memory from the current handle $this->destroy(); // Swap out the current handle for the new image handle. $this->handle = $handle; return $this; } /** * Watermark the image * * @param Image $watermark The Image object containing the watermark graphic * @param integer $transparency The transparency to use for the watermark graphic * @param integer $bottomMargin The margin from the bottom of this image * @param integer $rightMargin The margin from the right side of this image * * @return Image * * @since 1.3.0 * @link https://www.php.net/manual/en/image.examples-watermark.php */ public function watermark(Image $watermark, $transparency = 50, $bottomMargin = 0, $rightMargin = 0) { imagecopymerge( $this->getHandle(), $watermark->getHandle(), $this->getWidth() - $watermark->getWidth() - $rightMargin, $this->getHeight() - $watermark->getHeight() - $bottomMargin, 0, 0, $watermark->getWidth(), $watermark->getHeight(), $transparency ); return $this; } /** * Method to write the current image out to a file or output directly. * * @param mixed $path The filesystem path to save the image. * When null, the raw image stream will be outputted directly. * @param integer $type The image type to save the file as. * @param array $options The image type options to use in saving the file. * For PNG and JPEG formats use `quality` key to set compression level (0..9 and 0..100) * * @return boolean * * @link https://www.php.net/manual/image.constants.php * @since 1.0 * @throws \LogicException */ public function toFile($path, $type = IMAGETYPE_JPEG, array $options = array()) { switch ($type) { case IMAGETYPE_GIF: return imagegif($this->getHandle(), $path); case IMAGETYPE_PNG: return imagepng($this->getHandle(), $path, (array_key_exists('quality', $options)) ? $options['quality'] : 0); } // Case IMAGETYPE_JPEG & default return imagejpeg($this->getHandle(), $path, (array_key_exists('quality', $options)) ? $options['quality'] : 100); } /** * Method to get an image filter instance of a specified type. * * @param string $type The image filter type to get. * * @return ImageFilter * * @since 1.0 * @throws \RuntimeException */ protected function getFilterInstance($type) { // Sanitize the filter type. $type = strtolower(preg_replace('#[^A-Z0-9_]#i', '', $type)); // Verify that the filter type exists. $className = 'Joomla\\Image\\Filter\\' . ucfirst($type); if (!class_exists($className)) { $this->getLogger()->error('The ' . ucfirst($type) . ' image filter is not available.'); throw new \RuntimeException('The ' . ucfirst($type) . ' image filter is not available.'); } // Instantiate the filter object. $instance = new $className($this->getHandle()); // Verify that the filter type is valid. if (!($instance instanceof ImageFilter)) { // @codeCoverageIgnoreStart $this->getLogger()->error('The ' . ucfirst($type) . ' image filter is not valid.'); throw new \RuntimeException('The ' . ucfirst($type) . ' image filter is not valid.'); // @codeCoverageIgnoreEnd } return $instance; } /** * Method to get the new dimensions for a resized image. * * @param integer $width The width of the resized image in pixels. * @param integer $height The height of the resized image in pixels. * @param integer $scaleMethod The method to use for scaling * * @return \stdClass * * @since 1.0 * @throws \InvalidArgumentException If width, height or both given as zero */ protected function prepareDimensions($width, $height, $scaleMethod) { // Instantiate variables. $dimensions = new \stdClass; switch ($scaleMethod) { case self::SCALE_FILL: $dimensions->width = (int) round($width); $dimensions->height = (int) round($height); break; case self::SCALE_INSIDE: case self::SCALE_OUTSIDE: case self::SCALE_FIT: $rx = ($width > 0) ? ($this->getWidth() / $width) : 0; $ry = ($height > 0) ? ($this->getHeight() / $height) : 0; if ($scaleMethod != self::SCALE_OUTSIDE) { $ratio = max($rx, $ry); } else { $ratio = min($rx, $ry); } $dimensions->width = (int) round($this->getWidth() / $ratio); $dimensions->height = (int) round($this->getHeight() / $ratio); break; default: throw new \InvalidArgumentException('Invalid scale method.'); } return $dimensions; } /** * Method to sanitize a height value. * * @param mixed $height The input height value to sanitize. * @param mixed $width The input width value for reference. * * @return integer * * @since 1.0 */ protected function sanitizeHeight($height, $width) { // If no height was given we will assume it is a square and use the width. $height = ($height === null) ? $width : $height; // If we were given a percentage, calculate the integer value. if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $height)) { $height = (int) round($this->getHeight() * (float) str_replace('%', '', $height) / 100); } else { // Else do some rounding so we come out with a sane integer value. $height = (int) round((float) $height); } return $height; } /** * Method to sanitize an offset value like left or top. * * @param mixed $offset An offset value. * * @return integer * * @since 1.0 */ protected function sanitizeOffset($offset) { return (int) round((float) $offset); } /** * Method to sanitize a width value. * * @param mixed $width The input width value to sanitize. * @param mixed $height The input height value for reference. * * @return integer * * @since 1.0 */ protected function sanitizeWidth($width, $height) { // If no width was given we will assume it is a square and use the height. $width = ($width === null) ? $height : $width; // If we were given a percentage, calculate the integer value. if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width)) { $width = (int) round($this->getWidth() * (float) str_replace('%', '', $width) / 100); } else { // Else do some rounding so we come out with a sane integer value. $width = (int) round((float) $width); } return $width; } /** * Method to destroy an image handle and free the memory associated with the handle * * @return boolean True on success, false on failure or if no image is loaded * * @since 1.0 */ public function destroy() { if ($this->isLoaded()) { return imagedestroy($this->getHandle()); } return false; } /** * Method to call the destroy() method one last time to free any memory when the object is unset * * @see Image::destroy() * @since 1.0 */ public function __destruct() { $this->destroy(); } /** * Method for set option of generate thumbnail method * * @param boolean $quality True for best quality. False for best speed. * * @return void * * @since 1.4.0 */ public function setThumbnailGenerate($quality = true) { $this->generateBestQuality = (boolean) $quality; } /** * @param mixed $handle A potential image handle * * @return boolean */ private function isValidImage($handle) { // @todo Remove resource check, once PHP7 support is dropped. return (\is_resource($handle) && \get_resource_type($handle) === 'gd') || (\is_object($handle) && $handle instanceof \GDImage); } } src/ImageFilter.php 0000644 00000005333 15117027004 0010235 0 ustar 00 <?php /** * Part of the Joomla Framework Image Package * * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Image; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; /** * Class to manipulate an image. * * @since 1.0 * @deprecated The joomla/image package is deprecated */ abstract class ImageFilter implements LoggerAwareInterface { /** * @var resource|\GdImage The image resource handle. * @since 1.0 */ protected $handle; /** * @var LoggerInterface Logger object * @since 1.0 */ protected $logger; /** * Class constructor. * * @param resource|\GdImage $handle The image resource on which to apply the filter. * * @since 1.0 * @throws \InvalidArgumentException * @throws \RuntimeException */ public function __construct($handle) { // Verify that image filter support for PHP is available. if (!\function_exists('imagefilter')) { // @codeCoverageIgnoreStart $this->getLogger()->error('The imagefilter function for PHP is not available.'); throw new \RuntimeException('The imagefilter function for PHP is not available.'); // @codeCoverageIgnoreEnd } // Make sure the file handle is valid. if (!$this->isValidImage($handle)) { $this->getLogger()->error('The image handle is invalid for the image filter.'); throw new \InvalidArgumentException('The image handle is invalid for the image filter.'); } $this->handle = $handle; } /** * Get the logger. * * @return LoggerInterface * * @since 1.0 */ public function getLogger() { // If a logger hasn't been set, use NullLogger if (! ($this->logger instanceof LoggerInterface)) { $this->logger = new NullLogger; } return $this->logger; } /** * Sets a logger instance on the object * * @param LoggerInterface $logger A PSR-3 compliant logger. * * @return ImageFilter This object for message chaining. * * @since 1.0 */ public function setLogger(LoggerInterface $logger) { $this->logger = $logger; return $this; } /** * Method to apply a filter to an image resource. * * @param array $options An array of options for the filter. * * @return void * * @since 1.0 */ abstract public function execute(array $options = array()); /** * @param mixed $handle A potential image handle * * @return boolean */ private function isValidImage($handle) { // @todo Remove resource check, once PHP7 support is dropped. return (\is_resource($handle) && \get_resource_type($handle) === 'gd') || (\is_object($handle) && $handle instanceof \GDImage); } } image.php 0000644 00000004212 15117107321 0006334 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Editors-xtd.image * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Editor Image buton * * @since 1.5 */ class PlgButtonImage extends JPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.1 */ protected $autoloadLanguage = true; /** * Display the button. * * @param string $name The name of the button to display. * @param string $asset The name of the asset being edited. * @param integer $author The id of the author owning the asset being edited. * * @return JObject The button options as JObject or false if not allowed * * @since 1.5 */ public function onDisplay($name, $asset, $author) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $extension = $app->input->get('option'); // For categories we check the extension (ex: component.section) if ($extension === 'com_categories') { $parts = explode('.', $app->input->get('extension', 'com_content')); $extension = $parts[0]; } $asset = $asset !== '' ? $asset : $extension; if ($user->authorise('core.edit', $asset) || $user->authorise('core.create', $asset) || (count($user->getAuthorisedCategories($asset, 'core.create')) > 0) || ($user->authorise('core.edit.own', $asset) && $author === $user->id) || (count($user->getAuthorisedCategories($extension, 'core.edit')) > 0) || (count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author === $user->id)) { $link = 'index.php?option=com_media&view=images&tmpl=component&e_name=' . $name . '&asset=' . $asset . '&author=' . $author; $button = new JObject; $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_IMAGE_BUTTON_IMAGE'); $button->name = 'pictures'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; } return false; } } image.xml 0000644 00000001454 15117107321 0006352 0 ustar 00 <?xml version="1.0" encoding="utf-8"?> <extension version="3.1" type="plugin" group="editors-xtd" method="upgrade"> <name>plg_editors-xtd_image</name> <author>Joomla! Project</author> <creationDate>August 2004</creationDate> <copyright>Copyright (C) 2005 - 2020 Open Source Matters. All rights reserved.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <version>3.0.0</version> <description>PLG_IMAGE_XML_DESCRIPTION</description> <files> <filename plugin="image">image.php</filename> </files> <languages> <language tag="en-GB">en-GB.plg_editors-xtd_image.ini</language> <language tag="en-GB">en-GB.plg_editors-xtd_image.sys.ini</language> </languages> </extension>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.09 |
proxy
|
phpinfo
|
Настройка