	protected function imageMagickConvertPrepare($path, $destformat, $jpgQuality, $imageSize = null) {
		if (is_null($imageSize)) {
			$imageSize = getimagesize($path);
		}
		if (!$imageSize) {
			return array();
		}
		$srcType = $this->getExtentionByMime($imageSize['mime'], ':');
		$ani = false;
		$cmd = 'identify ' . escapeshellarg($srcType . $path);
		if ($this->procExec($cmd, $o) === 0) {
			$ani = preg_split('/(?:\r\n|\n|\r)/', trim($o));
			if (count($ani) < 2) {
				$ani = false;
			}
		}
		$coalesce = $index = '';
		$deconstruct = ' +repage';
		if ($ani) {
			if (is_null($destformat)) {
				$coalesce = ' -coalesce -repage 0x0';
				$deconstruct = ' +repage -deconstruct -layers optimize';
			} else {
				$index = '[0]';
				if ($srcType === 'ico:') {
					foreach($ani as $_i => $_info) {
						if (preg_match('/ (\d+)x(\d+) /', $_info, $m)) {
							if ($m[1] == $imageSize[0] && $m[2] == $imageSize[1]) {
								$index = '[' . $_i . ']';
								break;
							}
						}
					}
				}
			}
		}
		if ($imageSize[2] === IMAGETYPE_JPEG || $imageSize[2] === IMAGETYPE_JPEG2000) {
			$jpgQuality = ' -quality ' . $jpgQuality;
		} else {
			$jpgQuality = '';
		}
		$quotedPath = escapeshellarg($srcType . $path . $index);
		$quotedDstPath = escapeshellarg(($destformat? ($destformat . ':') : $srcType) . $path);
		return compact('ani', 'index', 'coalesce', 'deconstruct', 'jpgQuality', 'quotedPath', 'quotedDstPath');
	}
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.