Log in

View Full Version : PHP GD



Drompo
24-08-2007, 08:08 PM
I have this 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, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagepng($thumb);
?>

But it only outputs loads of ascii symbols

Drompo
24-08-2007, 08:47 PM
Half Fixed

<?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, $source, 0, 0, 0, 0, $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.

Want to hide these adverts? Register an account for free!