Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem ze skryptem
Markym
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 1.04.2006

Ostrzeżenie: (0%)
-----


  1.  
  2. <?
  3.  
  4. /*
  5.  * This script is copyright PHPGarage.com (On Line Construction Inc.). It may be used,
  6.  * changed, and distributed freely as long as this message and/or some type of recognition
  7.  * is given to PHPGarage.com or On Line Construction Inc.
  8.  * 
  9.  * http://www.phpgarage.com
  10.  * http://www.onlineconstructioninc.com
  11.  *
  12.  */
  13.  
  14. function ResizeImage($im,$maxwidth,$maxheight,$name){
  15. $width = imagesx($im);
  16. $height = imagesy($im);
  17. if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
  18. if($maxwidth && $width > $maxwidth){
  19. $widthratio = $maxwidth/$width;
  20. $RESIZEWIDTH=true;
  21. }
  22. if($maxheight && $height > $maxheight){
  23. $heightratio = $maxheight/$height;
  24. $RESIZEHEIGHT=true;
  25. }
  26. if($RESIZEWIDTH && $RESIZEHEIGHT){
  27. if($widthratio < $heightratio){
  28. $ratio = $widthratio;
  29. }else{
  30. $ratio = $heightratio;
  31. }
  32. }elseif($RESIZEWIDTH){
  33. $ratio = $widthratio;
  34. }elseif($RESIZEHEIGHT){
  35. $ratio = $heightratio;
  36. }
  37. $newwidth = $width * $ratio;
  38. $newheight = $height * $ratio;
  39. if(function_exists("imagecopyresampled")){
  40. $newim = imagecreatetruecolor($newwidth, $newheight);
  41. imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  42. }else{
  43. $newim = imagecreate($newwidth, $newheight);
  44. imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  45. }
  46. ImageJpeg ($newim,$name . ".jpg");
  47. ImageDestroy ($newim);
  48. }else{
  49. ImageJpeg ($im,$name . ".jpg");
  50. }
  51. }
  52.  
  53. ?>
  54.  
  55.  
  56. <?
  57.  
  58. // Filename to store image as (no extention)
  59. $FILENAME="image_name";
  60.  
  61. // Width to reszie image to (in pixels) 
  62. $RESIZEWIDTH=400;
  63.  
  64. // Width to reszie image to (in pixels) 
  65. $RESIZEHEIGHT=400;
  66.  
  67.  
  68. include("function.php");
  69.  
  70. if($_FILES['image']['size']){
  71. if($_FILES['image']['type'] == "image/pjpeg" || $_FILES['image']['type'] == "image/jpeg"){
  72. $im = imagecreatefromjpeg($_FILES['image']['tmp_name']);
  73. }elseif($_FILES['image']['type'] == "image/x-png" || $_FILES['image']['type'] == "image/png"){
  74. $im = imagecreatefrompng($_FILES['image']['tmp_name']);
  75. }elseif($_FILES['image']['type'] == "image/gif"){
  76. $im = imagecreatefromgif($_FILES['image']['tmp_name']);
  77. }
  78. if($im){
  79. if(file_exists("$FILENAME.jpg")){
  80. unlink("$FILENAME.jpg");
  81. }
  82. ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$FILENAME);
  83. ImageDestroy ($im);
  84. }
  85. }
  86.  
  87. ?>
  88. <img src="<? echo($FILENAME.".jpg?reload=".rand(0,999999)); ?>">


Skrypt fajnie skaluje mi fotki ale nie potrafię zrobić żeby zapisywał je w konkretnym folderze, teraz tworzy zeskalowaną fotkę w głównym katalogu gdzie jest umieszczony.
Go to the top of the page
+Quote Post

Posty w temacie
- Markym   Problem ze skryptem   3.04.2006, 19:55:03
- - Widmo   ZNAJDZ: [PHP] pobierz, plaintext <?phpif($...   12.04.2006, 00:23:54


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 11:40