public static function convert2Jpeg($inputImg, $savePath = null, $quality = null, array $exifData = null)
	{
		$retval = false;
		$img = self::imgCreate($inputImg);
		$imgSize = self::size($img);
		$jpegImg = imagecreatetruecolor($imgSize[0], $imgSize[1]);
		imagecopy($jpegImg, $img, 0, 0, 0, 0, $imgSize[0], $imgSize[1]);

		if (null === $quality)
			$quality = self::IMG_QUALITY;

		if (null !== $exifData && array_key_exists('Orientation', $exifData)) {
			$ort = $exifData['Orientation'];
			switch ($ort) {
				default:
				case 1: // nothing
					break;

				case 2: // horizontal flip
					$jpegImg = self::flipImage($jpegImg, 1);
					break;

				case 3: // 180 rotate left
					$jpegImg = self::rotateImage($jpegImg, 180);
					break;

				case 4: // vertical flip
					$jpegImg = self::flipImage($jpegImg, 2);
					break;

				case 5: // vertical flip + 90 rotate right
					$jpegImg = self::flipImage($jpegImg, 2);
					$jpegImg = self::rotateImage($jpegImg, 90);
					break;

				case 6: // 90 rotate right
					$jpegImg = self::rotateImage($jpegImg, 90);
					break;

				case 7: // horizontal flip + 90 rotate right
					$jpegImg = self::flipImage($jpegImg, 1);
					$jpegImg = self::rotateImage($jpegImg, 90);
					break;

				case 8:    // 90 rotate left
					$jpegImg = self::rotateImage($jpegImg, 270);
					break;
			}
		}

		if (null === $savePath)
			$retval = $jpegImg;
		else
			$retval = imagejpeg($jpegImg, $savePath, $quality);
		return $retval;
	}