Results 1 to 2 of 2

Thread: PHP GD

  1. #1
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default PHP GD

    I have this code
    PHP Code:
    <?php
    session_start
    ();
    ?>
    <?php
    // File and new size
    $path $_SESSION['path'];
    $filename $path;

    // Content type
    header('Content-type: image/png');

    // Get new sizes
    list($width$height) = getimagesize($filename);
    $newvalues $_SESSION['newvalues'];
    $explode explode('x'$newvalues);
    $newwidth $explode[0];
    $newheight $explode[1];

    // Load
    $thumb imagecreatetruecolor($newwidth$newheight);
    $source imagecreatefrompng($filename);

    // Resize
    imagecopyresized($thumb$source0000$newwidth$newheight$width$height);

    // Output
    imagepng($thumb);
    ?>
    But it only outputs loads of ascii symbols


  2. #2
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Half Fixed
    PHP Code:
    <?php
    session_start
    ();
    // File and new size
    $path $_SESSION["path"];
    $filename $path;

    // Content type
    header('Content-type: image/png');

    // Get new sizes
    list($width$height) = getimagesize($filename);
    $newvalues $_SESSION["newvalues"];
    $explode explode('x'$newvalues);
    $newwidth $explode[0];
    $newheight $explode[1];

    // Load
    $thumb imagecreatetruecolor($newwidth$newheight) or die("Cannot Initialize new GD image stream");
    $source imagecreatefrompng($filename);

    // Resize
    imagecopyresized($thumb$source0000$newwidth$newheight$width$height);

    // Output
    imagepng($thumb);
    ?>
    Now it just says
    The image “http://localhost/upload/index.php?action=upload” cannot be displayed, because it contains errors.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •