Автор Тема: Народ, что не так в скрипте?  (Прочитано 3669 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн Inecs

  • Завсегдатай
  • Новичок
  • *
  • Сообщений: 48
  • +0/-0
  • 0
    • Просмотр профиля
    • http://www.amorphis-dg.da.ru
Народ, что не так в скрипте?
« : 23 Января 2006, 22:03:14 »
Сабж. Не хочет делать маленькие картинки.
Поправьте меня, если что не так.

$gd_version = 2;

class thumbnail
{
   var $img;
    var $watermark_image_light;
    var $watermark_image_dark;

   function thumbnail($imgfile)
   {
      //detect image format
      $this->img["format"]=ereg_replace(".*\\.(.*)$","\\\\1",$imgfile);
      $this->img["format"]=strtoupper($this->img["format"]);
      if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
         //JPEG
         $this->img["format"]="JPEG";
         $this->img["src"] = ImageCreateFromJPEG ($imgfile);
      } elseif ($this->img["format"]=="PNG") {
         //PNG
         $this->img["format"]="PNG";
         $this->img["src"] = ImageCreateFromPNG ($imgfile);
      } elseif ($this->img["format"]=="GIF") {
         //GIF
         $this->img["format"]="GIF";
         $this->img["src"] = ImageCreateFromGIF ($imgfile);
      } else {
         //DEFAULT
         echo "Not Supported File! Thumbnails can only be made from .jpg and .png images!";
         exit();
      }
      $this->img["lebar"] = imagesx($this->img["src"]);
      $this->img["tinggi"] = imagesy($this->img["src"]);
      $this->img["lebar_thumb"] = $this->img["lebar"];
      $this->img["tinggi_thumb"] = $this->img["tinggi"];
      //default quality jpeg
      $this->img["quality"]=90;
   }

function size_auto($size=100)
{ global $gd_version;

      if ($this->img["lebar"] < $size AND $this->img["tinggi"] < $size ) {
      $this->img["lebar_thumb"] = $this->img["lebar"];
      $this->img["tinggi_thumb"] = $this->img["tinggi"];
      return 0;
   } elseif ($this->img["lebar"]>=$this->img["tinggi"])
      {
          $this->img["lebar_thumb"]=$size;
          $this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
      } else {
          $this->img["tinggi_thumb"]=$size;
          $this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
    }

   if($gd_version==1)
          {
           $this->img["des"] = imagecreate($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
          @imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
         }
   elseif($gd_version==2)
           {
            $this->img["des"] = imagecreatetruecolor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
           @imagecopyresampled ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
           }

   $this->img["src"] = $this->img["des"];
   return 1;
}

function jpeg_quality($quality=90)
   {
      //jpeg quality
      $this->img["quality"]=$quality;
   }

function save($save="")
{

       if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
         //JPEG
         imageJPEG($this->img["src"],"$save",$this->img["quality"]);
      } elseif ($this->img["format"]=="PNG") {
         //PNG
         imagePNG($this->img["src"],"$save");
      } elseif ($this->img["format"]=="GIF") {
         //GIF
         imageGIF($this->img["src"],"$save");
      }

      imagedestroy($this->img["src"]);
}


function show ()
{
      if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
         //JPEG
         imageJPEG($this->img["src"],"",$this->img["quality"]);
      } elseif ($this->img["format"]=="PNG") {
         //PNG
         imagePNG($this->img["src"]);
      } elseif ($this->img["format"]=="GIF") {
         //GIF
         imageGIF($this->img["src"]);
      }

      imagedestroy($this->img["src"]);
}
?>

Оффлайн Меняздесьдавнонет

  • новичЕк
  • Глобальный модератор
  • Ветеран
  • *****
  • Сообщений: 5698
  • +0/-0
  • 2
    • Просмотр профиля
    • http://
Народ, что не так в скрипте?
« Ответ #1 : 23 Января 2006, 22:49:43 »
шикарный вопос

Оффлайн Slastik

  • Фанат форума
  • Постоялец
  • ***
  • Сообщений: 101
  • +0/-0
  • 0
    • Просмотр профиля
    • http://www.sproekt.kiev.ua
Народ, что не так в скрипте?
« Ответ #2 : 23 Января 2006, 23:39:37 »
Цитировать
Поправьте меня, если что не так

подтверждаю именно так
не хочет делать
:)
FAQ OFF =)

Оффлайн fuza

  • Завсегдатай
  • Пользователь
  • **
  • Сообщений: 51
  • +0/-0
  • 0
    • Просмотр профиля
    • http://komptex.narod.ru
Народ, что не так в скрипте?
« Ответ #3 : 26 Января 2006, 00:00:05 »
да, мой друг твой километровый код, никто смотреть не будет :))))

 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28