	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ) {

		if (!$jpgQuality) {
			$jpgQuality = $this->options['jpgQuality'];
		}
		
		try {
			if ($destformat) {
				if ($destformat === 'gif') {
					$img->setImageFormat('gif');
				} else if ($destformat === 'png') {
					$img->setImageFormat('png');
				} else if ($destformat === 'jpg') {
					$img->setImageFormat('jpeg');
				}
			}
			if (strtoupper($img->getImageFormat()) === 'JPEG') {
				$img->setImageCompression(imagick::COMPRESSION_JPEG);
				$img->setImageCompressionQuality($jpgQuality);
				try {
					$orientation = $img->getImageOrientation();
				} catch (ImagickException $e) {
					$orientation = 0;
				}
				$img->stripImage();
				if ($orientation) {
					$img->setImageOrientation($orientation);
				}
			}
			$result = $img->writeImage($filename);
		} catch (Exception $e) {
			$result = false;
		}
		
		return $result;
	}
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.