function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1) { if (gif_outputAsBmp($gif, "{$lpszFileName}.bmp", $gbColor)) { exec("cjpeg {$lpszFileName}.bmp >{$lpszFileName} 2>/dev/null"); @unLink("{$lpszFileName}.bmp"); if (@file_exists($lpszFileName)) { if (@fileSize($lpszFileName) > 0) { return true; } @unLink($lpszFileName); } } return false; }
function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1) { // JPEG output that does not require cjpeg added by James Heinrich <*****@*****.**> - December 10, 2003 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && (file_exists('/usr/local/bin/cjpeg') || `which cjpeg`)) { if (gif_outputAsBmp($gif, $lpszFileName . '.bmp', $bgColor)) { exec('cjpeg ' . $lpszFileName . '.bmp >' . $lpszFileName . ' 2>/dev/null'); @unLink($lpszFileName . '.bmp'); if (@file_exists($lpszFileName)) { if (@fileSize($lpszFileName) > 0) { return true; } @unLink($lpszFileName); } } } else { // either Windows, or cjpeg not found in path if ($img = @ImageCreateFromString($gif->getPng($bgColor))) { if (@ImageJPEG($img, $lpszFileName)) { return true; } } } return false; }