I am currently setting up site to display my garments. Ive decided use one file and resize the images in php. Ive read a lot about GD. Still not to sure how it is implemnted though. What happens is when i resize the image, it looks like crap. This is the code im using.
<?php
// The file
$filename = 'test.jpg';
$percent = 0.5;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, null, 100);
?>[/quote]
Now just adapt it to fit your needs. You might wanna use $_GET['filename'] to pass the image by GET and use something like <img src="res_img.php?filename=8200fwmc4.jpg">
-- Scorphus
did you add the script to an existing script? That's why.
The script example scorphus posted is a stand-alone script. It cannot have any other junk around it or you will get garbage on the browser. The script generates an image directly to the browser.
feyd wrote:did you add the script to an existing script? That's why.
The script example scorphus posted is a stand-alone script. It cannot have any other junk around it or you will get garbage on the browser. The script generates an image directly to the browser.
... which basically means that the script generates (and outputs) an image, which you link to like a normal image:
yep, im using scorphus code. I added my own filename, but the bigger the file i put into the script the more jibberish i get coming out. This seems to tell me that the code in itself is working. I cannot output the image though.
are you sure you don't have extra stuff in the file? Line breaks of any sort on either side of the <? and ?> will do it... literally anything outside of php tags will... along with any echo's will mangle the output.
My mistake, i found a short gd script and ran it with the same results. I had one extra line above the first <? and was getting all that crap. Wow i cant believe that was it.