help generating thumnails (more of a php question)

help generating thumnails (more of a php question)

I've been watching a couple tutorials on how to do this put none of them seem to work, but the code I made to upload the original photo works. Here's what I'm having trouble with:

functional upload image php func
  1. function upload_comic_img($image_temp, $image_ext, $comic_id) {
        $comic_id = (int)$comic_id;
       
        mysql_query("INSERT INTO `images` VALUES('', '".$_SESSION['ID']."', '$comic_id', UNIX_TIMESTAMP(), '$image_ext')");
       
        $image_id = mysql_insert_id();
        $image_file = $image_id.'.'.$image_ext;
        move_uploaded_file($image_temp, 'uploads/'.$comic_id.'/'.$image_file);
       
        create_comic_thumb('uploads/'.$comic_id.'/'. $image_file);
    }









dysfunctional create thumb php func
  1. function create_comic_thumb($path) {
        $image = $path;
       
        $image_size = getimagesize($image);
        $image_width = $image_size[0];
        $image_height = $image_size[1];
       
        $new_size = ($image_width + $image_height)/($image_width*($image_height*45));
        $new_width = $image_width * $new_size;
        $new_height = $image_height * $new_size;
       
        $new_image = imagecreatetruecolor($new_width, $new_height);
       
        if ($image_ext == 'image/png') {
            $old_image = imagecreatefrompng($image);
        //} else if ($image == 'image/jpeg') {
            //$old_image = imagecreatefromjpeg($image);
        //} else if ($image == 'image/gif') {
            //$old_image = imagecreatefromgif($image);
        } else {
            echo 'img prob';
        }

        imagecopyresized($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);
       
        imagepng ($new_image, $image. 'uploads/thumbs/'.$comic_id.'/'.$image_file);
        //imagejpeg ($new_image, 'uploads/thumbs/'.$comic_id.'/'.$image_file);
        //imagegif ($new_image, 'uploads/thumbs/'.$comic_id.'/'.$image_file);
    }



























Is there a quicker way to just resize to the uploaded img with jquery so I don't have to fill up my server with smaller versions of already available images?

Anyway, here's the code for the page I eventually want the thumbnails to end up on just in case it helps:
  1. <?php
    $comic_id = $_GET['comic_id'];
    $comic_data = comic_data($comic_id, 'name', 'desc');
    $images = get_images($comic_id);
    ?>
    <div class="blackout"></div>

    <div class="view_comic">
        <div class="comic_close"></div>
            <div class="comic_navl" ></div>
            <div class="comic_navr"></div>
                <div class="comic_img">
                    <img src="">
                </div>
    </div>

    <?php
    echo '<p>', $comic_data['name'], '</p>';

    if (empty($images)) {
        echo 'There are no images in this file.';
    } else {
        foreach ($images as $image) {   //add thumb to uploads
            echo '<div><img class="page" src="uploads/', $image['comic'], '/', $image['id'], '.', $image['ext'], '"
                              title="Uploaded ', date('D M Y / h:i:s', $image['timestamp']), '"
                              alt="image" >
                  </div>';
                if(admin_check() === true) {
                echo '[<a href="delete_image.php?image_id=', $image['id'],'">x</a>]';
                } else {
                }
        }
    }
    ?>




































Inside the first couple of divs is gonna be my image gallery where I want the full sized image to appear.