HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/hcv/wp-content/plugins/timber-library/lib/Image/Operation.php
<?php

namespace Timber\Image;

/**
 * Each image filter is represented by a subclass of this class,m
 * and each filter call is a new instance, with call arguments as properties.
 * 
 * Only 3 methods need to be implemented:
 * - constructor, storing all filter arguments
 * - filename
 * - run
 */
abstract class Operation {
	/**
	 *
	 * Builds the result filename, based on source filename and extension
	 * 
	 * @param  string $src_filename  source filename (excluding extension and path)
	 * @param  string $src_extension source file extension
	 * @return string                resulting filename (including extension but excluding path)
	 *                               ex: my-awesome-file.jpg
	 */
	public abstract function filename( $src_filename, $src_extension );

	/**
	 * Performs the actual image manipulation,
	 * including saving the target file.
	 * 
	 * @param  string $load_filename filepath (not URL) to source file
	 * @param  string $save_filename filepath (not URL) where result file should be saved
	 * @return bool                  true if everything went fine, false otherwise
	 */
	public abstract function run( $load_filename, $save_filename );

	/**
	 * Helper method to convert hex string to rgb array
	 * 
	 * @param  string $hexstr hex color string (like '#FF1455', 'FF1455', '#CCC', 'CCC')
	 * @return array          array('red', 'green', 'blue') to int
	 *                        ex: array('red' => 255, 'green' => 20, 'blue' => 85);
	 */
	public static function hexrgb( $hexstr ) {
		$hexstr = str_replace('#', '', $hexstr);
		if ( strlen($hexstr) == 3 ) {
			$hexstr = $hexstr[0].$hexstr[0].$hexstr[1].$hexstr[1].$hexstr[2].$hexstr[2];
		}
		$int = hexdec($hexstr);
		return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($int >> 0x8), "blue" => 0xFF & $int);
	}

	public static function rgbhex( $r, $g, $b ) {
		return '#' . sprintf('%02x', $r) . sprintf('%02x', $g) . sprintf('%02x', $b);
	}
}