SILENT KILLERPanel

Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > jetpack > _inc > lib >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//ameliagraphics.com/wp-content/plugins/jetpack/_inc/lib/

NameTypeSizeLast ModifiedActions
admin-pages Directory - -
core-api Directory - -
debugger Directory - -
markdown Directory - -
class-jetpack-ai-helper.php File 14554 bytes May 19 2025 19:32:00.
class-jetpack-blog-stats-helper.php File 2798 bytes April 14 2025 18:35:52.
class-jetpack-currencies.php File 4847 bytes July 15 2024 22:48:12.
class-jetpack-instagram-gallery-helper.php File 2986 bytes April 22 2024 23:41:02.
class-jetpack-mapbox-helper.php File 3232 bytes November 08 2022 02:55:22.
class-jetpack-podcast-feed-locator.php File 3554 bytes April 28 2025 19:38:34.
class-jetpack-podcast-helper.php File 20716 bytes April 28 2025 19:38:34.
class-jetpack-recommendations.php File 15603 bytes February 26 2024 23:23:14.
class-jetpack-top-posts-helper.php File 4588 bytes May 05 2025 21:43:40.
class.color.php File 22310 bytes August 20 2024 12:34:10.
class.core-rest-api-endpoints.php File 151622 bytes April 28 2025 19:38:34.
class.jetpack-automatic-install-skin.php File 293 bytes September 20 2023 01:19:10.
class.jetpack-iframe-embed.php File 3178 bytes June 19 2023 23:16:28.
class.jetpack-password-checker.php File 33225 bytes April 16 2024 00:40:26.
class.jetpack-search-performance-logger.php File 3711 bytes March 29 2022 23:04:42.
class.media-extractor.php File 22088 bytes August 13 2024 00:04:40.
class.media-summary.php File 15803 bytes June 05 2025 20:49:04.
class.media.php File 15936 bytes May 06 2024 23:42:24.
components.php File 3111 bytes May 26 2025 19:03:40.
debugger.php File 872 bytes January 23 2024 00:02:16.
icalendar-reader.php File 33905 bytes February 24 2025 22:55:34.
markdown.php File 344 bytes September 22 2022 21:43:06.
plans.php File 1935 bytes January 25 2022 23:38:06.
plugins.php File 209 bytes February 02 2022 21:44:30.
tonesque.php File 7015 bytes August 20 2024 12:34:10.
widgets.php File 26822 bytes May 06 2024 23:42:24.

Reading File: /home/codekrsu//ameliagraphics.com/wp-content/plugins/jetpack/_inc/lib//tonesque.php

<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
 * Tonesque
 * Grab an average color representation from an image.
 *
 * @author Automattic
 * @author Matias Ventura
 * @package automattic/jetpack
 */

if ( ! class_exists( 'Tonesque' ) ) {
	/**
	 * Color representation class.
	 */
	class Tonesque {
		/**
		 * Image URL.
		 *
		 * @var string
		 */
		private $image_url = '';
		/**
		 * Image identifier representing the image.
		 *
		 * @var null|object
		 */
		private $image_obj = null;
		/**
		 * Color code.
		 *
		 * @var string
		 */
		private $color = '';

		/**
		 * Constructor.
		 *
		 * @param string $image_url Image URL.
		 */
		public function __construct( $image_url ) {
			_deprecated_function( 'Tonesque::__construct', 'jetpack-13.8' );

			if ( ! class_exists( 'Jetpack_Color' ) ) {
				require_once JETPACK__PLUGIN_DIR . '/_inc/lib/class.color.php';
			}

			$this->image_url = esc_url_raw( $image_url );
			$this->image_url = trim( $this->image_url );
			/**
			 * Allows any image URL to be passed in for $this->image_url.
			 *
			 * @module theme-tools
			 *
			 * @since 2.5.0
			 *
			 * @param string $image_url The URL to any image
			 */
			$this->image_url = apply_filters( 'tonesque_image_url', $this->image_url );

			$this->image_obj = self::imagecreatefromurl( $this->image_url );
		}

		/**
		 * Get an image object from a URL.
		 *
		 * @param string $image_url Image URL.
		 *
		 * @return object|bool Image object or false if the image could not be loaded.
		 */
		public static function imagecreatefromurl( $image_url ) {
			_deprecated_function( 'Tonesque::imagecreatefromurl', 'jetpack-13.8' );

			$data = null;

			// If it's a URL.
			if ( preg_match( '#^https?://#i', $image_url ) ) {
				// If it's a url pointing to a local media library url.
				$content_url = content_url();
				$_image_url  = set_url_scheme( $image_url );
				if ( str_starts_with( $_image_url, $content_url ) ) {
					$_image_path = str_replace( $content_url, WP_CONTENT_DIR, $_image_url );
					if ( file_exists( $_image_path ) ) {
						$filetype = wp_check_filetype( $_image_path );
						$type     = $filetype['type'];

						if ( str_starts_with( $type, 'image/' ) ) {
							$data = file_get_contents( $_image_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
						}
					}
				}

				if ( empty( $data ) ) {
					$response      = wp_safe_remote_get( $image_url );
					$response_code = wp_remote_retrieve_response_code( $response );
					if (
						is_wp_error( $response )
						|| ! $response_code
						|| $response_code < 200
						|| $response_code >= 300
					) {
						return false;
					}
					$data = wp_remote_retrieve_body( $response );
				}
			}

			// If it's a local path in our WordPress install.
			if ( file_exists( $image_url ) ) {
				$filetype = wp_check_filetype( $image_url );
				$type     = $filetype['type'];

				if ( str_starts_with( $type, 'image/' ) ) {
					$data = file_get_contents( $image_url ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
				}
			}

			if ( null === $data ) {
				return false;
			}

			// Now turn it into an image and return it.
			return imagecreatefromstring( $data );
		}

		/**
		 * Construct object from image.
		 *
		 * @param string $type Type (hex, rgb, hsv) (optional).
		 *
		 * @return string|bool color as a string formatted as $type or false if the image could not be loaded.
		 */
		public function color( $type = 'hex' ) {
			// Bail if there is no image to work with.
			if ( ! $this->image_obj ) {
				return false;
			}

			// Finds dominant color.
			$color = self::grab_color();
			// Passes value to Color class.
			return self::get_color( $color, $type );
		}

		/**
		 * Grabs the color index for each of five sample points of the image
		 *
		 * @param string $type can be 'index' or 'hex'.
		 *
		 * @return array|false color indices or false if the image could not be loaded.
		 */
		public function grab_points( $type = 'index' ) {
			$img = $this->image_obj;
			if ( ! $img ) {
				return false;
			}

			$height = imagesy( $img );
			$width  = imagesx( $img );

			/*
			* Sample five points in the image
			* based on rule of thirds and center.
			*/
			$topy    = round( $height / 3 );
			$bottomy = round( ( $height / 3 ) * 2 );
			$leftx   = round( $width / 3 );
			$rightx  = round( ( $width / 3 ) * 2 );
			$centery = round( $height / 2 );
			$centerx = round( $width / 2 );

			// Cast those colors into an array.
			$points = array(
				imagecolorat( $img, $leftx, $topy ),
				imagecolorat( $img, $rightx, $topy ),
				imagecolorat( $img, $leftx, $bottomy ),
				imagecolorat( $img, $rightx, $bottomy ),
				imagecolorat( $img, $centerx, $centery ),
			);

			if ( 'hex' === $type ) {
				foreach ( $points as $i => $p ) {
					$c            = imagecolorsforindex( $img, $p );
					$points[ $i ] = self::get_color(
						array(
							'r' => $c['red'],
							'g' => $c['green'],
							'b' => $c['blue'],
						),
						'hex'
					);
				}
			}

			return $points;
		}

		/**
		 * Finds the average color of the image based on five sample points
		 *
		 * @return array|bool array with rgb color or false if the image could not be loaded.
		 */
		public function grab_color() {
			$img = $this->image_obj;
			if ( ! $img ) {
				return false;
			}

			$rgb = self::grab_points();

			$r = array();
			$g = array();
			$b = array();

			/*
			* Process the color points
			* Find the average representation
			*/
			foreach ( $rgb as $color ) {
				$index = imagecolorsforindex( $img, $color );
				$r[]   = $index['red'];
				$g[]   = $index['green'];
				$b[]   = $index['blue'];
			}
			$red   = round( array_sum( $r ) / 5 );
			$green = round( array_sum( $g ) / 5 );
			$blue  = round( array_sum( $b ) / 5 );

			// The average color of the image as rgb array.
			$color = array(
				'r' => $red,
				'g' => $green,
				'b' => $blue,
			);

			return $color;
		}

		/**
		 * Get a Color object using /lib class.color
		 * Convert to appropriate type
		 *
		 * @param string $color Color code.
		 * @param string $type  Color type (rgb, hex, hsv).
		 *
		 * @return string
		 */
		public function get_color( $color, $type ) {
			$c           = new Jetpack_Color( $color, 'rgb' );
			$this->color = $c;

			switch ( $type ) {
				case 'rgb':
					$color = implode( ',', $c->toRgbInt() );
					break;
				case 'hex':
					$color = $c->toHex();
					break;
				case 'hsv':
					$color = implode( ',', $c->toHsvInt() );
					break;
				default:
					return $c->toHex();
			}

			return $color;
		}

		/**
		 *
		 * Checks contrast against main color
		 * Gives either black or white for using with opacity
		 *
		 * @return string|bool Returns black or white or false if the image could not be loaded.
		 */
		public function contrast() {
			if ( ! $this->color ) {
				return false;
			}

			$c = $this->color->getMaxContrastColor();
			return implode( ',', $c->toRgbInt() );
		}
	}
}

SILENT KILLER Tool