CoreFiles by mySites.guru
ImageFilter.php66 lines, 1,540 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
147b5f8cea3be464d35b8a86b89df8b3
sha1
7db18e89838357517de6d6f7e0fbe084a5458b6b
sha256
5764417ff622e319bea1e158f27c170569987418712905581c5a0b167b1c0c5a
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Image;

\defined('JPATH_PLATFORM') or die;

/**
 * Class to manipulate an image.
 *
 * @since  2.5.0
 */
abstract class ImageFilter
{
	/**
	 * @var    resource  The image resource handle.
	 * @since  2.5.0
	 */
	protected $handle;

	/**
	 * Class constructor.
	 *
	 * @param   resource  $handle  The image resource on which to apply the filter.
	 *
	 * @since   2.5.0
	 * @throws  \InvalidArgumentException
	 * @throws  \RuntimeException
	 */
	public function __construct($handle)
	{
		// Verify that image filter support for PHP is available.
		if (!\function_exists('imagefilter'))
		{
			throw new \RuntimeException('The imagefilter function for PHP is not available.');
		}

		/**
		 * Make sure the file handle is valid.
		 * TODO: Remove check for resource when we only support PHP 8
		 */
		if (!((\is_object($handle) && get_class($handle) == 'GdImage')
			|| (\is_resource($handle) && get_resource_type($handle) == 'gd')))
		{
			throw new \InvalidArgumentException('The image handle is invalid for the image filter.');
		}

		$this->handle = $handle;
	}

	/**
	 * Method to apply a filter to an image resource.
	 *
	 * @param   array  $options  An array of options for the filter.
	 *
	 * @return  void
	 *
	 * @since   2.5.0
	 */
	abstract public function execute(array $options = []);
}

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.