国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php修改上傳圖片尺寸的方法

2024-05-04 23:34:15
字體:
供稿:網(wǎng)友

這篇文章主要介紹了php修改上傳圖片尺寸的方法,涉及php操作圖片的技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了php修改上傳圖片尺寸的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

 

 
  1. <?php 
  2. // This is the temporary file created by PHP 
  3. $uploadedfile = $_FILES['uploadfile']['tmp_name']; 
  4. // Create an Image from it so we can do the resize 
  5. $src = imagecreatefromjpeg($uploadedfile); 
  6. // Capture the original size of the uploaded image 
  7. list($width,$height)=getimagesize($uploadedfile); 
  8. // For our purposes, I have resized the image to be 
  9. // 600 pixels wide, and maintain the original aspect 
  10. // ratio. This prevents the image from being "stretched" 
  11. // or "squashed". If you prefer some max width other than 
  12. // 600, simply change the $newwidth variable 
  13. $newwidth=600; 
  14. $newheight=($height/$width)*600; 
  15. $tmp=imagecreatetruecolor($newwidth,$newheight); 
  16. // this line actually does the image resizing, copying from the original 
  17. // image into the $tmp image 
  18. imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); 
  19. // now write the resized image to disk. I have assumed that you want the 
  20. // resized, uploaded image file to reside in the ./images subdirectory. 
  21. $filename = "images/"$_FILES['uploadfile']['name']; 
  22. imagejpeg($tmp,$filename,100); 
  23. imagedestroy($src); 
  24. imagedestroy($tmp); 
  25. // NOTE: PHP will clean up the temp file it created when the request 
  26. // has completed. 
  27. ?> 

希望本文所述對大家的php程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 攀枝花市| 太原市| 西乡县| 鄂托克旗| 扎赉特旗| 清涧县| 湖北省| 康乐县| 康平县| 西贡区| 潢川县| 武山县| 延庆县| 明溪县| 临湘市| 巩义市| 塔城市| 安图县| 彩票| 温泉县| 水富县| 志丹县| 合江县| 恩平市| 菏泽市| 天祝| 博白县| 台北市| 金寨县| 古浪县| 定兴县| 广昌县| 万宁市| 洛南县| 方山县| 内丘县| 揭阳市| 邢台市| 五寨县| 边坝县| 南京市|