[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Image/ -> ImageFilter.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Image;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('JPATH_PLATFORM') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Class to manipulate an image.
  18   *
  19   * @since  1.7.3
  20   */
  21  abstract class ImageFilter
  22  {
  23      /**
  24       * @var    resource  The image resource handle.
  25       * @since  2.5.0
  26       */
  27      protected $handle;
  28  
  29      /**
  30       * Class constructor.
  31       *
  32       * @param   resource  $handle  The image resource on which to apply the filter.
  33       *
  34       * @since   1.7.3
  35       * @throws  \InvalidArgumentException
  36       * @throws  \RuntimeException
  37       */
  38      public function __construct($handle)
  39      {
  40          // Verify that image filter support for PHP is available.
  41          if (!\function_exists('imagefilter')) {
  42              throw new \RuntimeException('The imagefilter function for PHP is not available.');
  43          }
  44  
  45          /**
  46           * Make sure the file handle is valid.
  47           * @todo: Remove check for resource when we only support PHP 8
  48           */
  49          if (
  50              !((\is_object($handle) && get_class($handle) == 'GdImage')
  51              || (\is_resource($handle) && get_resource_type($handle) == 'gd'))
  52          ) {
  53              throw new \InvalidArgumentException('The image handle is invalid for the image filter.');
  54          }
  55  
  56          $this->handle = $handle;
  57      }
  58  
  59      /**
  60       * Method to apply a filter to an image resource.
  61       *
  62       * @param   array  $options  An array of options for the filter.
  63       *
  64       * @return  void
  65       *
  66       * @since   2.5.0
  67       */
  68      abstract public function execute(array $options = []);
  69  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer