Hi there,
I'm writing a script to resize images for a list of thumbnails I want to display on my web site. I followed a tutorial and got some help form various places and came up with the following code...
<?php
header('Content-type: image/jpeg');
$filename = '1.jpg';
list($width, $height) = getimagesize($filename);
$new_height = 100;
$new_width = ($new_height / $height) * $width;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_p, null, 100);
?>
You'll have to bear with me 😛 Although I've been using PHP since 2000 I've never done images before. Basically this seemed like a good way to do it, but it takes such a long time to generate and display all the images when I've got like 50 per page (these are huge 4MB+ files we're resizing here) ans I'm sure it must be pretty intensive on the server when I've got 5+ people at once requestiong them. So what I want to do is where I've got that 1.jpg I'm resizing instead of doing that I want to do this so it will save it as 1s.jpg...Then I can just call the JPEGs instead of the PHP scripts and I can put this code after the upload script. Anyone know how I can save the resized image instead of outputting it?
Thanks