  	protected function imgCrop($path, $width, $height, $x, $y, $destformat = null, $jpgQuality = null) {
		if (($s = @getimagesize($path)) == false) {
			return false;
		}

		$result = false;
		
		if (!$jpgQuality) {
			$jpgQuality = $this->options['jpgQuality'];
		}

		switch ($this->imgLib) {
			case 'imagick':
				
				try {
					$img = new imagick($path);
				} catch (Exception $e) {
					return false;
				}
				
				$ani = ($img->getNumberImages() > 1);
				if ($ani && is_null($destformat)) {
					$img = $img->coalesceImages();
					do {
						$img->setImagePage($s[0], $s[1], 0, 0);
						$img->cropImage($width, $height, $x, $y);
						$img->setImagePage($width, $height, 0, 0);
					} while ($img->nextImage());
					$img = $img->optimizeImageLayers();
					$result = $img->writeImages($path, true);
				} else {
					if ($ani) {
						$img->setFirstIterator();
					}
					$img->setImagePage($s[0], $s[1], 0, 0);
					$img->cropImage($width, $height, $x, $y);
					$img->setImagePage($width, $height, 0, 0);
					$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);
				}
				
				$img->clear();

				return $result ? $path : false;

				break;

			case 'gd':
				$img = $this->gdImageCreate($path,$s['mime']);

				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) {
					
					$this->gdImageBackground($tmp,$this->options['tmbBgColor']);

					$size_w = $width;
					$size_h = $height;

					if ($s[0] < $width || $s[1] < $height) {
						$size_w = $s[0];
						$size_h = $s[1];
					}

					if (!imagecopy($tmp, $img, 0, 0, $x, $y, $size_w, $size_h)) {
						return false;
					}
					
					$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);

					imagedestroy($img);
					imagedestroy($tmp);

					return $result ? $path : false;

				}
				break;
		}

		return false;
	}
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.