HELP API Output to JPEG Using PHP and GD

[size=1]Ok, i got the source from Jerry Jasuta to build a Drawing API, everything works perfectly it draws and saves the images into jpg. I have a little problem, how do i make it load images to the same file, I want to be able to load pictures and draw on them then save them into jpg.[/size]

[size=1]Need help …Please…[/size]

[size=1]Actionscripting in the frame,[/size]

drawing=false;
data=’’;

createEmptyMovieClip(’_keyListener’,1);
Key.addListener(_keyListener);
_keyListener.onKeyDown=function(){
clear();
_root.data=’’;
};

with(_root)

onMouseDown=function(){
drawing=true;
startX=_xmouse;
startY=_ymouse;
moveTo(startX,startY);
};
onMouseUp=function(){
drawing=false;
};
onMouseMove=function(){
if(drawing==true){
lineStyle(2);
lineTo(_xmouse,_ymouse);

if(drawing==true && _ymouse<200){
lineStyle(2);
lineTo(_xmouse,ymouse);
root.data+=startX+’’+startY+’
’+xmouse+’’+_ymouse+’-’;
startX=_xmouse;
startY=_ymouse;
}
updateAfterEvent();
};
}

[color=red]This makes the PHP Part work,[/color]

$data=$HTTP_POST_VARS[“data”];

$image=imagecreatetruecolor(300,200);
$imagelines=imagecreate(300,200);

$background=imagecolorallocate($imagelines,255,255,255);
$linecolor=imagecolorallocate($imagelines,0,0,0);

$lines=explode("-",$data);

for($l=0;$l<count($lines)-1;$l++){

$lineData=explode("_",$lines[$l]);

imageline($imagelines,$lineData[0],$lineData[1],$lineData[2],$lineData[3],$linecolor);
}

imagecopyresampled($image,$imagelines,0,0,0,0,300,200,300,200);

imagejpeg($image,“created.jpg”);

imagedestroy($image);
imagedestroy($imagelines);

print "<html>
<head>
<title></title>
</head>
<body bgColor=‘cccccc’>
<center>
<p>
<img src=‘created.jpg’>
</center>
</body>
</html>