PHP GD How to Save Images?

Discussion in 'OT Technology' started by doggfather, Jun 10, 2006.

  1. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    <?php
    // The file
    $filename = '001.jpg';
    // Set a maximum height and width
    $width = 200;
    $height = 200;
    // Content type
    header('Content-type: image/jpeg');
    // Get new dimensions
    list($width_orig, $height_orig) = getimagesize($filename);
    if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
    } else {
    $height = ($width / $width_orig) * $height_orig;
    }
    // Resample
    $image_p = imagecreatetruecolor($width, $height);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    // Output
    imagejpeg($image_p, null, 100);
    ?>


    I want to save the resampled 001.jpg on the server....how would I do that?
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,914
    Likes Received:
    8
    Location:
    Los Angeles
    Use the [ php] tags and I'll look at it.
     

Share This Page