The method for creating thumbnails in php is also very simple. It is to use imagecopyresampled to create a smaller image based on the source image. Let's look at the code check_image_addthumbs.php? Php changes image effects $ dbmysql_connect (localhost, root, Ctrip07185419) ordie (cannotconnecttodatabase)
The method for creating thumbnails in php is also very simple. It is to use imagecopyresampled to create a smaller image based on the source image. Let's look at the code check_image_addthumbs.php? Php // modify image effects $ db = mysql_connect ('localhost', 'root', 'ctrip07185419 ') or die ('can not connect to database ')
The method for creating thumbnails in php is also very simple. You can use imagecopyresampled to create a smaller image based on the source image. Let's look at the code check_image_addthumbs.php.
Here is your pic! Your image has been saved! $ _ POST ['id'];?>. Jpg "alt =" "/>
Here is your pic! So how does it feel to be famous?Here is the picture you just uploaded to your servers:
$ Imagename;?> "Style =" float: left; "alt =" "/>
| Image save: |
|
| Height: |
|
| Widht: |
|
| Upload date: |
|
You may apply a special effect to your image from the list of option below. Note: saving an image with any of the filters appliedCan be undone
The thumbnail is placed under the path D: \ Serious \ phpdev \ test \ images \ thumbs. Here we add a gallery. php file to display all the thumbnails. The Code is as follows:
Welcome to our Photo Gallery Click on any image to see it full sized.
| Image |
Caption |
Uploaded By |
Date uploaded |
' : '
'; $odd = !$odd; extract($row); echo '
| $dir . '/' . $image_id.'.jpg">'; echo '$thumbdir . '/' . $image_id . '.jpg" alt="" />'; echo ' | '; echo '
'.$image_caption.' | '; echo '
'.$image_username.' | '; echo '
'.$image_date.' | '; echo '
'; } ?>
To see the effect of the thumbnail:
Note the following code:
$ Thumb_width = $ width * 0.10; $ thumb_height = $ height * 0.10; // create a thumbnail $ thumb = imagecreatetruecolor ($ thumb_width, $ thumb_height); imagecopyresampled ($ thumb, $ image, 0, 0, 0, 0, $ thumb_width, $ thumb_height, $ width, $ height); // Save the original image imagejpeg ($ image, $ dir. '/'. $ _ POST ['id']. '.jpg ', 100); // Save the thumbnail imagejpeg ($ thumb, $ thumbdir. '/'. $ _ POST ['id']. '.jpg ', 100); imagedestroy ($ thumb );
We set the thumbnail length to 10% of the original length, and the width to 10% of the original width. Make sure that the width is the same. Otherwise, the image will be distorted. Of course, if this parameter is set to an integer greater than 1, the image is enlarged.