hey guyz,
i finnaly got my gd library running and cant wait to get my own thumbnail generation script.... well here is exactly what need.....
The code that you supply has to be complete...
i use a form to upload an image ... form has field name "image" :
ok now what i want is a script that will use this same image to generate a thumbnail of it...
the thumbnail should :
width = 115 px
height = (in ratio to width.. but maximum of 140..clipping if excess)
ok now once it has been generated it has to be sent to a folder :
modules/templates/thumb/
the name of it has to be the same as the image... the name is randomly generated ... so you can use "$id" to get the same name for the thumb as the image itself... and then enter the value into the database using this code :
this will enter the same value as the image so no error occurs...
Note : The extention on the thumb has to be the same as the image. and that the code should be enough so that i can simply add to my existing page....
i currently use a manually uploading script to upload the thumb... the script you supply has to be so that i can simply replace my older script (very much similar to the above script) with this new one !
thnx !
i finnaly got my gd library running and cant wait to get my own thumbnail generation script.... well here is exactly what need.....
The code that you supply has to be complete...
i use a form to upload an image ... form has field name "image" :
| Code: |
| $maxfilesize = 1000000;
// check if there was a file uploaded if (!is_uploaded_file($_FILES['image']['tmp_name'])) { $error = "<b>you didn't select a file to upload.</b><br />"; // if it was, go ahead with other checks } else { if ($_FILES['image']['size'] > $maxfilesize) { $error = "<b>your image file was too large.</b><br />"; unlink($_FILES['image']['tmp_name']); } else { $ext = strrchr($_FILES['image']['name'], "."); if ($ext != ".gif" AND $ext != ".jpg" AND $ext != ".jpeg" AND $ext != ".GIF" AND $ext != ".JPG" AND $ext != ".JPEG") { $error = "your file was an unacceptable type.<br />"; unlink($_FILES['image']['tmp_name']); // if it's there, an okay size and type, copy to server and update the photo value in SQL } else { $newname = $id.$ext; move_uploaded_file($_FILES['image']['tmp_name'],"modules/templates/images/".$newname); mysql_query("UPDATE templates SET image='$newname' WHERE id= '$id'") or die (mysql_error()); } } } |
ok now what i want is a script that will use this same image to generate a thumbnail of it...
the thumbnail should :
width = 115 px
height = (in ratio to width.. but maximum of 140..clipping if excess)
ok now once it has been generated it has to be sent to a folder :
modules/templates/thumb/
the name of it has to be the same as the image... the name is randomly generated ... so you can use "$id" to get the same name for the thumb as the image itself... and then enter the value into the database using this code :
this will enter the same value as the image so no error occurs...
| Code: |
| mysql_query("UPDATE templates SET thumb='$newname' WHERE id= '$id'") or die (mysql_error()); |
Note : The extention on the thumb has to be the same as the image. and that the code should be enough so that i can simply add to my existing page....
i currently use a manually uploading script to upload the thumb... the script you supply has to be so that i can simply replace my older script (very much similar to the above script) with this new one !
thnx !
