Sto impazzendo per una cosa semplicissima

ho questo codice:

Codice PHP:
$image 'myfile.jpg';

//read orientation information from EXIF

$exif exif_read_data($filename);
$ort $exif['IFD0']['Orientation'];

//then based on $ort you can determine the rotation degree,
//check the link below for more info

//rotation degree
$degrees 180;

// create "image object"
$source imagecreatefromjpeg($image) ;

// rotate
$rotate imagerotate($source$degrees0) ;

// set the header
header('Content-type: image/jpeg') ;

// output
imagejpeg($rotate) ; 
come faccio a fare questo:

Codice PHP:
sostituisci l'immagine $rotate al file 'myfile.jpg';