PHP creates corrupt thumnbail
<p>This is the thumnbail script I'm working on and it ends up creating a corrupt 33 byte image. I think the problem is in the exif_imagetype if statement but I'm not sure. I would appreciate any help.</p>

<pre><code>    // Original image
    $filename = 'images/T' . $neutralName;

    // Get dimensions of the original image
    list($current_width, $current_height) = getimagesize($filename);

    // The x and y coordinates on the original image where we
    // will begin cropping the image
    $left = 10;
    $top = 5;

    // This will be the final size of the image (e.g. how many pixels
    // left and down we will be going)
    $crop_width = 140;
    $crop_height = 100;

    // Resample the image
    $canvas = imagecreatetruecolor($crop_width, $crop_height);
    if ((exif_imagetype($_FILES['photo']['tmp_name'])) == IMAGETYPE_JPEG) {
        $current_image = imagecreatefromjpeg($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagejpeg($canvas, $filename, 100);
    } else if ((exif_imagetype($_FILES["photo"]['tmp_name'])) == IMAGETYPE_GIF) {
        $current_image = imagecreatefromgif($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagegif($canvas, $filename, 100);
    } else {
        $current_image = imagecreatefrompng($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagepng($canvas, $filename, 100);
    }
</code></pre>
