public function __construct($input) { $percent = 50; $h_align = CGImage_Crop_Filter::ALIGN_CENTER; $v_align = CGImage_Crop_Filter::ALIGN_CENTER; if (cge_array::is_hash($input)) { $percent = (int) $input['percent']; $h_align = trim($params['h']); $v_align = trim($params['v']); } else { if (is_array($input)) { if (count($input) > 1) { $percent = (int) $input[0]; } if (count($input) == 3) { $h_align = trim($input[1]); $v_align = trim($input[2]); } } } $this->_percent = min(100, max(1, $percent)); switch ($h_align) { case '-1': case 'left': case 'l': $this->_h_align = self::ALIGN_LEFT; break; case '0': case 'c': case 'center': $this->_h_align = self::ALIGN_CENTER; break; case '1': case 'r': case 'right': $this->_h_align = self::ALIGN_RIGHT; break; default: throw new Exception('Invalid value ' . $h_align . ' for horizontal alignment'); } switch ($v_align) { case '-1': case 't': case 'top': $this->_v_align = self::ALIGN_TOP; break; case '0': case 'c': case 'center': $this->_v_align = self::ALIGN_CENTER; break; case '1': case 'b': case 'bottom': $this->_v_align = self::ALIGN_BOTTOM; break; default: throw new Exception('Invalid value ' . $h_align . ' for horizontal alignment'); } }
public function __construct($input) { if (cge_array::is_hash($input)) { if (isset($input['width'])) { $this->_dest_w = (int) $input['width']; $this->_dest_h = (int) $input['height']; } else { if (isset($input['w'])) { $this->_dest_w = (int) $input['w']; $this->_dest_h = (int) $input['h']; } } if (isset($input['loc']) && in_array($input['loc'], self::$_valid_locs)) { $this->_loc = trim($input['loc']); } } else { if (is_array($input)) { if (count($input) >= 2) { $this->_dest_w = (int) trim($input[0]); $this->_dest_h = (int) trim($input[1]); if (count($input) >= 3 && in_array($input[2], self::$_valid_locs)) { $this->_loc = trim($input[2]); } } } } if ($this->_dest_h <= 0 || $this->_dest_w <= 0) { throw new Exception('Invalid values specified for Croptofit filter constructor'); } }
public function __construct() { $input = func_get_args(); if (is_array($input) && count($input) == 1) { $input = $input[0]; } $this->_divisor = array_sum(array_map('array_sum', $this->_matrix)); $adj = 0; if (cge_array::is_hash($input) && isset($input['divisor'])) { $adj = (double) $input['divisor']; } else { if (is_array($input) && count($input) >= 1) { $adj = (double) $input[0]; } } $this->_divisor += max(-10, min(10, $adj)); }
public function __construct() { $input = func_get_args(); if (count($input) == 1 && is_array($input[0])) { $input = $input[0]; } if (cge_array::is_hash($input)) { $this->_wmtext = \cge_param::get_string($input, 'text'); } else { if (is_array($input) && count($input) >= 1) { $tmp = \cge_param::get_string($input, 0); if (is_string($tmp) && !is_numeric($tmp)) { $this->_wmtext = $tmp; } } } }
public function __construct($input) { $mod = cms_utils::get_module('CGSmartImage'); $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c'); if (cge_array::is_hash($input)) { if (isset($input['width'])) { $this->_dest_w = (int) $input['width']; $this->_dest_h = (int) $input['height']; } else { if (isset($input['w'])) { $this->_dest_w = (int) $input['w']; $this->_dest_h = (int) $input['h']; } } if (isset($input['color']) && $input['color'] != '') { $this->_color = strtolower($input['color']); } if (isset($input['alpha'])) { $this->_alpha = (int) $input['alpha']; } } else { if (is_array($input)) { if (count($input) >= 2) { $this->_dest_w = (int) trim($input[0]); $this->_dest_h = (int) trim($input[1]); if (count($input) >= 3) { if ($input[2] != '') { $this->_color = strtolower($input[2]); } if (count($input) >= 4) { if ($input[3] != '') { $this->_alpha = (int) $input[3]; } } } } } } $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w); $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h); $this->_alpha = max(0, min(127, $this->_alpha)); // todo: convert color name into rgb. if ($this->_dest_h <= 0 || $this->_dest_w <= 0) { throw new Exception('Invalid values specified for Croptofit filter constructor'); } }
public function __construct($input) { $mod = cms_utils::get_module('CGSmartImage'); $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c'); if (cge_array::is_hash($input)) { if (isset($input['width'])) { $this->_dest_w = (int) $input['width']; $this->_dest_h = (int) $input['height']; } else { if (isset($input['w'])) { $this->_dest_w = (int) $input['w']; $this->_dest_h = (int) $input['h']; } } if (isset($input['loc']) && in_array($input['loc'], self::$_valid_locs)) { $this->_loc = $input['loc']; } if (isset($input['upscale'])) { $this->_upscale = (int) $input['upscale']; } } else { if (is_array($input)) { if (count($input) >= 2) { $this->_dest_w = (int) trim($input[0]); $this->_dest_h = (int) trim($input[1]); if (count($input) >= 3 && in_array($input[2], self::$_valid_locs)) { $this->_loc = $input[2]; } if (count($input) >= 4) { $this->_upscale = (int) $input[3]; } } } } if (!$this->_upscale) { $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w); $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h); } if ($this->_dest_h <= 0 || $this->_dest_w <= 0) { throw new Exception('Invalid values specified for Croptofit filter constructor'); } }
public function __construct($input) { if (cge_array::is_hash($input)) { if (isset($input['radius'])) { $this->_radius = (int) $input['radius']; } if (isset($input['color'])) { $this->_color = $input['color']; } } else { if (is_array($input)) { if (count($input) >= 1) { $this->_radius = (int) $input[0]; } if (count($input) >= 2) { $this->_color = $input[1]; } } } if ($this->_radius <= 1) { throw new Exception('Invalid values specified for Roundedcorners filter constructor'); } }
public function __construct() { $input = func_get_args(); if (count($input) == 1 && is_array($input[0])) { $input = $input[0]; } if (cge_array::is_hash($input)) { if (isset($input['width'])) { $this->_width = (int) $input['width']; } if (isset($input['height'])) { $this->_height = (int) $input['height']; } if (isset($input['percent'])) { $this->_percent = (int) $input['percent']; $this->_percent = min(100, max(1, $this->_percent)); } if (isset($input['resample'])) { $this->_resample = (int) $input['resample']; } if (isset($input['upscale'])) { $this->_upscale = (int) $input['upscale']; } if (isset($input['edge'])) { $this->_edge = (int) $input['edge']; } } else { if (is_array($input) && count($input) >= 2) { $idx = 2; switch ($input[0]) { case 'p': $this->_percent = (int) $input[1]; break; case 'w': $this->_width = (int) $input[1]; break; case 'h': $this->_height = (int) $input[1]; break; case 'e': $this->_edge = (int) $input[1]; case 'c': $this->_width = (int) $input[1]; $this->_height = (int) $input[2]; $idx = 3; break; } if (count($input) > $idx) { $this->_upscale = (int) $input[$idx]; } } } if ($this->_width > 0) { $this->_width = cgsi_utils::trim_to_device('width', $this->_width); } if ($this->_height > 0) { $this->_height = cgsi_utils::trim_to_device('height', $this->_height); } if (!($this->_percent > 0 || $this->_width > 0 || $this->_height > 0 || $this->_edge > 0)) { throw new Exception('Could not Create Resize Filter - Invalid Parameters'); } }