Beginning Ajax with PHP From Novice to Professional phần 6

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 img img amp sml s onclick changesize img s return false Small a a href img img amp sml m onclick changesize img m return false Medium a a href 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 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
476    18    1    29-11-2024
24    21    1    29-11-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.