<?php
/*###########################################################
SIMPLY GD SCRIPT BY MICHAEL FILTENBORG
I FINALLY GOT THE IMAGES TOO LOOK GOOD
THE KEY IS TO USE ImageCreateTrueColor() not ImageCreate and
ImageCopyResampled() and not ImageCopyResized, finally
you should display as a png.
Unfortunately for those who have GD 1.9 or lower
those 2 functions are not in until GD 2.0 or higher
ENJOY!!!!
###############################################*/
//just set your images here!
//set an action for every image you want to use,
//you can alter this as you wish offcourse :)
if($action == "totm") {
$filename = "totm.jpg";
} elseif ($action == "haylicole") {
$filename = "chicks/HayliCole.JPG";
//more elseif's for every pic you want to use
} else {
$filename = "you suck, you didn't select a file :)";
}
// get you image sizes so we can resize them :)
$imageInfo = getimagesize($filename);
//giant if elseif just to resize more or less depending on image size :)
if($imageInfo['0'] >= "600" && $imageInfo['0'] <= "800"
&& $imageInfo['1'] >= "400"
&& $imageInfo['1'] <= "600") {
$new_w = ($imagew / 2);
$new_h = ($imageh / 2);
} elseif ($imageInfo['0'] >= "600"
&& $imageInfo['1'] <= "400" && $imageInfo['1'] >= "800"
&& $imageInfo['1'] <= "600") {
//small image so set size!
$new_w = ($imagew + 100 /2);
$new_w = ($imageh + 100 /2);
} elseif ($imageInfo['0'] <= "800" && $imageInfo['0'] <= "1000" && $imageInfo['1'] >= "600"
&& $imageInfo['1'] <= "800") {
//image is between 800/1000 in width and 600/800 in height, so do
$new_w = ($imagew / 3);
$new_h = ($imageh / 3);
} else {
//image is bigger then neccessary, resize smaller
$new_w = ($imagew / 3);
$new_h = ($imageh / 3);
}
//set img src = filename
$img_src ="$filename";
//create your image and set it as dst_img
//function only in GD 2 or higher!
$dst_img=ImageCreateTrueColor($new_w,$new_h);
//your new src_img your creating the image from a jpg
$src_img=ImageCreateFromJpeg("$filename");
//now use function imagecoypresampled(NOT RESIZED!)
//for more quality purposes
//function only in GD 2 or highter!
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,
$imageInfo['0'],$imageInfo['1']);
//display image as a png.
ImagePng($dst_img, '', 100);
?>
this took me a long time to get done with, so i hope it helps others... now for your page taht is going to actuall dispaly your iamges you would use this
for action of totm
<a href="url_to_full_size.jpg"><img src=your_file_name.php?action=totm border=0></a>
and so on... this is working very well for me, if anyone finds a bug or finds anything else wrong please let me know and if you have any suggestions, let me know too 🙂
ENJOY! 😉