Просмотр файла gallery/resize.php

Размер файла: 3.05Kb
  1. <?php
  2. #-----------------------------------------------------#
  3. # ********* WAP-MOTORS ********* #
  4. # Made by : VANTUZ #
  5. # E-mail : visavi.net@mail.ru #
  6. # Site : http://pizdec.ru #
  7. # WAP-Site : http://visavi.net #
  8. # ICQ : 36-44-66 #
  9. # Вы не имеете право вносить изменения в код скрипта #
  10. #-----------------------------------------------------#
  11. require_once"../template/start.php";
  12. require_once"../template/regglobals.php";
  13. require_once"../template/config.php";
  14. require_once"../template/functions.php";
  15.  
  16.  
  17. if($gdir!="" && $gpoddir!="" && $gname!=""){
  18.  
  19. if($maxsize==""){$maxsize = 100;}
  20.  
  21. $image=BASEDIR."$gdir/$gpoddir/$gname";
  22.  
  23. if($act=="jpg"){
  24. $size = GetImageSize($image);
  25. $width = $size[0];
  26. $height = $size[1];
  27.  
  28. $x_ratio = $maxsize / $width;
  29. $y_ratio = $maxsize / $height;
  30.  
  31. if ( ($width <= $maxsize) && ($height <= $maxsize) ) {
  32. $tn_width = $width;
  33. $tn_height = $height;
  34. }
  35. else if (($x_ratio * $height) < $maxsize) {
  36. $tn_height = ceil($x_ratio * $height);
  37. $tn_width = $maxsize;
  38. }
  39. else {
  40. $tn_width = ceil($y_ratio * $width);
  41. $tn_height = $maxsize;
  42. }
  43.  
  44. $src = ImageCreateFromJpeg($image);
  45. $dst = ImageCreateTrueColor($tn_width,$tn_height);
  46. ImageCopyResized($dst, $src, 0, 0, 0, 0,
  47. $tn_width,$tn_height,$width,$height);
  48. header("Content-type: image/jpeg");
  49. ImageJpeg ($dst, null, 40);
  50. ImageDestroy($src);
  51. ImageDestroy($dst); }
  52. if($act=="gif"){
  53. $size = GetImageSize($image);
  54. $width = $size[0];
  55. $height = $size[1];
  56.  
  57. $x_ratio = $maxsize / $width;
  58. $y_ratio = $maxsize / $height;
  59.  
  60. if ( ($width <= $maxsize) && ($height <= $maxsize) ) {
  61. $tn_width = $width;
  62. $tn_height = $height;
  63. }
  64. else if (($x_ratio * $height) < $maxsize) {
  65. $tn_height = ceil($x_ratio * $height);
  66. $tn_width = $maxsize;
  67. }
  68. else {
  69. $tn_width = ceil($y_ratio * $width);
  70. $tn_height = $maxsize;
  71. }
  72.  
  73. $src = ImageCreateFromGif($image);
  74. $dst = ImageCreateTrueColor($tn_width,$tn_height);
  75. ImageCopyResized($dst, $src, 0, 0, 0, 0,
  76. $tn_width,$tn_height,$width,$height);
  77. header("Content-type: image/gif");
  78. ImageGif ($dst);
  79. ImageDestroy($src);
  80. ImageDestroy($dst); }
  81. if($act=="png"){
  82. $size = GetImageSize($image);
  83. $width = $size[0];
  84. $height = $size[1];
  85.  
  86. $x_ratio = $maxsize / $width;
  87. $y_ratio = $maxsize / $height;
  88.  
  89. if ( ($width <= $maxsize) && ($height <= $maxsize) ) {
  90. $tn_width = $width;
  91. $tn_height = $height;
  92. }
  93. else if (($x_ratio * $height) < $maxsize) {
  94. $tn_height = ceil($x_ratio * $height);
  95. $tn_width = $maxsize;
  96. }
  97. else {
  98. $tn_width = ceil($y_ratio * $width);
  99. $tn_height = $maxsize;
  100. }
  101.  
  102. $src = ImageCreateFromPng($image);
  103. $dst = ImageCreateTrueColor($tn_width,$tn_height);
  104. ImageCopyResized($dst, $src, 0, 0, 0, 0,
  105. $tn_width,$tn_height,$width,$height);
  106. header("Content-type: image/png");
  107. ImagePng ($dst);
  108. ImageDestroy($src);
  109. ImageDestroy($dst); }
  110. }
  111. ?>