Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'beginning ajax with php from novice to professional phần 6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 98 CHAPTER 6 IMAGES Create the thumbnail. func types thepath extension 1 func dst filename img src filename alt p Change Image Size a href thumb.php img img amp sml s onclick changesize img s return false Small a a href thumb.php img img amp sml m onclick changesize img m return false Medium a a href thumb.php img img amp sml l onclick changesize img l return false Large a p php return echo No image found. createthumb _GET img _GET sml The first function you should notice in the thumb.php file is setWidthHeight. This function s sole purpose is to find a properly sized set of image coordinates based on a scaled-down size. In other words it will take an image s width and height as arguments as well as a maximum width and height and then return a scaled-down width and height based on the passed-in arguments. The next function createthumb is a tad more complicated. The createthumb function takes in an image path as well as a size argument to decide what type of image to create. This particular function can have its constraints set to make a thumbnail based on the small med and large variable arguments at the top of the function. It will then attempt to locate the image path. If the path is found it will figure out the new size arguments by calling the setWidthHeight function and then use the appropriate image-creation function based on whether the image in question is a JPEG GIF or PNG. You determine this by using an array containing each of the image types along with their associated GD functions for reading and writing images of that type. Once a thumbnail has been successfully created the script will output the newly created thumbnail and then show the same navigation as before allowing the user to create a new thumbnail of a different size if necessary. CHAPTER 6 IMAGES 99 The nice thing about all of this is that it comes together in a seamless package. Everything from uploading a new image to dynamically resizing the image is fast and efficient with maximum user .