Saving an image as a black square?

I sort of made an image cropping tool

select an image to crop, submit the form, crop the image, save and the cropped image appeasrs below.
But the image is totally black?
Heres the PHP bit t o save the cropped image

$t_width = 300;    // Maximum thumbnail width
$t_height = 300;    // Maximum thumbnail height
$new_name = "feature.jpg"; // Thumbnail image name
$path = "../providers/images/{$_GET['id']}/";

if(isset($_GET['t']) and $_GET['t'] == "ajax")
        $ratio = ($t_width/$w); 
        $nw = ceil($w * $ratio);
        $nh = ceil($h * $ratio);
        $nimg = imagecreatetruecolor($nw,$nh);
        $im_src = imagecreatefromjpeg($path.$img);
        echo $new_name;

Doo you see what the problem could be?

when I echo out
$nimg = imagecreatetruecolor($nw,$nh);

I get Resource id #1

but when I echo $im_src, I get nothing

what does that mean?

I selected a jpg type image, cropped it and it worked.
So I gather I need to convert all my images to JPGs first, is there a way to convert all images in a directory of type (gif, png, and bmp to jpgs)?