class_mcImage.inc.php 1005 Bytes
<?php

class mcImage {
	
	/**
	 * 
	 * @param string $param_svgFileString
	 */
	public static function pngToJpg($param_in_png, $param_out_jpg=false, $param_quality=100) {
		
		if($param_out_jpg === false) {
			$param_out_jpg = tempnam("/tmp", "mcImage_");
			$tmp_jpg = $param_out_jpg.'.jpg';
			mcFile::rename($param_out_jpg, $tmp_jpg);
			$param_out_jpg = $tmp_jpg;
		}
		
		$shell_exec = mcImage::GD_pngToJpg($param_in_png, $param_out_jpg, $param_quality);	

//		D::show($shell_exec);
		
		if($shell_exec) {
			return $param_out_jpg;
		} else {
			return false;
		}
		
		
	}

	/**
	 * 
	 * GD library
	 * 
	 * @param type $originalFile
	 * @param type $outputFile
	 * @param type $quality - Quality is a number between 0 (best compression) and 100 (best quality)
	 */
	protected static function GD_pngToJpg($originalFile, $outputFile, $quality) {
		$image = imagecreatefrompng($originalFile);
		$return = imagejpeg($image, $outputFile, $quality);
		imagedestroy($image);
		return $return;
	}	
	
	
}
?>