src/Image.php
protected function cropDefaults($fpSrc, $vals)
	{
		$this->debug->groupcollapsed(__METHOD__);
		// src Defaults
		if (empty($vals['src_type']) || empty($vals['src_w']) || empty($vals['src_h'])) {
			// $this->debug->log('determine src info');
			$imageInfo = $fpSrc == 'data'
				? getimagesizefromstring($vals['src_data'])
				: getimagesize($fpSrc);
			// $this->debug->log('imageInfo', $imageInfo);
			if ($imageInfo) {
				$imageInfoVals = array(
					'src_type'	=> $imageInfo[2],
					'src_w'		=> $imageInfo[0],
					'src_h'		=> $imageInfo[1],
				);
				foreach (array('src_type','src_w','src_h') as $k) {
					if (empty($vals[$k])) {
						$vals[$k] = $imageInfoVals[$k];
					}
				}
			}
		}
		// $this->debug->log('vals', $vals);
		foreach (array('src_type','dst_type') as $type) {
			if (is_int($vals[$type])) {
				$vals[$type] = image_type_to_extension($vals[$type], false);	// false = no dot
			} elseif ($vals[$type] == 'jpg') {
				$vals[$type] = 'jpeg';
			}
		}
		if (empty($vals['dst_w'])) {
			$vals['dst_w'] = $vals['src_w'];
		}
		if (empty($vals['dst_h'])) {
			$vals['dst_h'] = $vals['src_h'];
		}
		if (is_string($vals['color_bg'])) {
			$vals['color_bg'] = array_values($this->hex2rgb($vals['color_bg']));
		}
		if (empty($vals['opts'])) {
			$quality = $vals['quality'];
			if ($vals['dst_type'] == 'png') {
				$vals['quality'] = round(abs(($quality - 100) / 11.111111));	// convert 0-100 "quality" to 0-9 "compression"
			}
			$vals['opts'] = array( $vals['quality'] );
		}
		// $this->debug->log('vals', $vals);
		$this->debug->groupEnd();
		return $vals;
	}
protected function cropDefaults($fpSrc, $vals)
	{
		$this->debug->groupcollapsed(__METHOD__);
		// src Defaults
		if (empty($vals['src_type']) || empty($vals['src_w']) || empty($vals['src_h'])) {
			// $this->debug->log('determine src info');
			$imageInfo = $fpSrc == 'data'
				? getimagesizefromstring($vals['src_data'])
				: getimagesize($fpSrc);
			// $this->debug->log('imageInfo', $imageInfo);
			if ($imageInfo) {
				$imageInfoVals = array(
					'src_type'	=> $imageInfo[2],
					'src_w'		=> $imageInfo[0],
					'src_h'		=> $imageInfo[1],
				);
				foreach (array('src_type','src_w','src_h') as $k) {
					if (empty($vals[$k])) {
						$vals[$k] = $imageInfoVals[$k];
					}
				}
			}
		}
		// $this->debug->log('vals', $vals);
		foreach (array('src_type','dst_type') as $type) {
			if (is_int($vals[$type])) {
				$vals[$type] = image_type_to_extension($vals[$type], false);	// false = no dot
			} elseif ($vals[$type] == 'jpg') {
				$vals[$type] = 'jpeg';
			}
		}
		if (empty($vals['dst_w'])) {
			$vals['dst_w'] = $vals['src_w'];
		}
		if (empty($vals['dst_h'])) {
			$vals['dst_h'] = $vals['src_h'];
		}
		if (is_string($vals['color_bg'])) {
			$vals['color_bg'] = array_values($this->hex2rgb($vals['color_bg']));
		}
		if (empty($vals['opts'])) {
			$quality = $vals['quality'];
			if ($vals['dst_type'] == 'png') {
				$vals['quality'] = round(abs(($quality - 100) / 11.111111));	// convert 0-100 "quality" to 0-9 "compression"
			}
			$vals['opts'] = array( $vals['quality'] );
		}
		// $this->debug->log('vals', $vals);
		$this->debug->groupEnd();
		return $vals;
	}
protected function cropDefaults ( $ fpSrc , $ vals ) { $ this -> debug -> groupcollapsed ( __METHOD__ ) ; // src Defaults if ( empty ( $ vals [ 'src_type' ] ) || empty ( $ vals [ 'src_w' ] ) || empty ( $ vals [ 'src_h' ] ) ) { // $this->debug->log('determine src info'); $ imageInfo = $ fpSrc == 'data' ? getimagesizefromstring ( $ vals [ 'src_data' ] ) : getimagesize ( $ fpSrc ) ; // $this->debug->log('imageInfo', $imageInfo); if ( $ imageInfo ) { $ imageInfoVals = array ( 'src_type' => $ imageInfo [ 2 ] , 'src_w' => $ imageInfo [ 0 ] , 'src_h' => $ imageInfo [ 1 ] , ) ; foreach ( array ( 'src_type' , 'src_w' , 'src_h' ) as $ k ) { if ( empty ( $ vals [ $ k ] ) ) { $ vals [ $ k ] = $ imageInfoVals [ $ k ] ; } } } } // $this->debug->log('vals', $vals); foreach ( array ( 'src_type' , 'dst_type' ) as $ type ) { if ( is_int ( $ vals [ $ type ] ) ) { $ vals [ $ type ] = image_type_to_extension ( $ vals [ $ type ] , false ) ; // false = no dot } elseif ( $ vals [ $ type ] == 'jpg' ) { $ vals [ $ type ] = 'jpeg' ; } } if ( empty ( $ vals [ 'dst_w' ] ) ) { $ vals [ 'dst_w' ] = $ vals [ 'src_w' ] ; } if ( empty ( $ vals [ 'dst_h' ] ) ) { $ vals [ 'dst_h' ] = $ vals [ 'src_h' ] ; } if ( is_string ( $ vals [ 'color_bg' ] ) ) { $ vals [ 'color_bg' ] = array_values ( $ this -> hex2rgb ( $ vals [ 'color_bg' ] ) ) ; } if ( empty ( $ vals [ 'opts' ] ) ) { $ quality = $ vals [ 'quality' ] ; if ( $ vals [ 'dst_type' ] == 'png' ) { $ vals [ 'quality' ] = round ( abs ( ( $ quality - 100 ) / 11.111111 ) ) ; // convert 0-100 "quality" to 0-9 "compression" } $ vals [ 'opts' ] = array ( $ vals [ 'quality' ] ) ; } // $this->debug->log('vals', $vals); $ this -> debug -> groupEnd ( ) ; return $ vals ; }
get default & normalize crop parameters

@param string $fpSrc file path or 'data'
@param array  $vals  paramaters

@return mixed
get default & normalize crop parameters