Giris

$mesaj

Üye Adi Sifre
| Üye ol

Online Sayisi : 34 Toplam Üye Sayisi : 1586 Son Üye : okan109

Tarih 2008:Nov:Sat

Kategoriler
  • ACPI [0]

  • Action Script [5]

  • Ajax [7]

  • ASP [17]

  • ASP.NET [23]

  • Assembly [3]

  • Bash [1]

  • C [6]

  • C# [9]

  • C++ [12]

  • Cobol [1]

  • Css [20]

  • Delphi [31]

  • Flash [5]

  • Html [9]

  • JAVA [36]

  • Java Script [17]

  • JSF [2]

  • Jsp [6]

  • Lua [1]

  • Matlab [2]

  • MySQL [31]

  • Oracle [1]

  • Pascal [31]

  • Pear [3]

  • Perl [22]

  • Photoshop [2]

  • PHP [169]

  • Python [9]

  • REXX [6]

  • Ruby [4]

  • SEO [5]

  • Visual Basic [37]

  • PHP / Resim Yüklerken Küçük Resim Oluşturma Kodu
    Resim Yüklerken Küçük Resim Oluşturma Kodu
    Yazar: FERDIKUCUK
    Eklenme: 15/09/08    Okunma: 434    
     
     


     Kod Çizelgesi     Kod Dili: "php"
    <?
    ##############################################
    # Shiege Iseng Resize Class
    # 11 March 2005
    # shiegegeATyahoo.com
    # http://shiege.com/scripts/thumbnail/
    /*############################################
    Sample :
    $thumb=new thumbnail("./shiegege.jpg");            // generate image_file, set filename to resize/resample
    $thumb->size_width(100);                        // set width for thumbnail, or
    $thumb->size_height(300);                        // set height for thumbnail, or
    $thumb->size_auto(200);                            // set the biggest width or height for thumbnail
    $thumb->jpeg_quality(75);                        // [OPTIONAL] set quality for jpeg only (0 - 100) (worst - best), default = 75
    $thumb->show();                                    // show your thumbnail
    $thumb->save("./huhu.jpg");                        // save your thumbnail to file
    ----------------------------------------------
    Note :
    - GD must Enabled
    - Autodetect file extension (.jpg/jpeg, .png, .gif, .wbmp)
      but some server can't generate .gif / .wbmp file types
    - If your GD not support 'ImageCreateTrueColor' function,
      change one line from 'ImageCreateTrueColor' to 'ImageCreate'
      (the position in 'show' and 'save' function)
    - If your GD not support 'ImageCopyResampled' function,
      change 'ImageCopyResampled' to 'ImageCopyResize'
    */############################################


    class thumbnail
    {
        var 
    $img;

        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);
            } elseif (
    $this->img["format"]=="WBMP") {
                
    //WBMP
                
    $this->img["format"]="WBMP";
                
    $this->img["src"] = ImageCreateFromWBMP ($imgfile);
            } else {
                
    //DEFAULT
                
    echo "Not Supported File";
                exit();
            }
            @
    $this->img["lebar"] = imagesx($this->img["src"]);
            @
    $this->img["tinggi"] = imagesy($this->img["src"]);
            
    //default quality jpeg
            
    $this->img["quality"]=75;
        }

        function 
    size_height($size=100)
        {
            
    //height
            
    $this->img["tinggi_thumb"]=$size;
            @
    $this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
        }

        function 
    size_width($size=100)
        {
            
    //width
            
    $this->img["lebar_thumb"]=$size;
            @
    $this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
        }

        function 
    size_auto($size=100)
        {
            
    //size
            
    if ($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"];
             }
        }

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

        function 
    show()
        {
            
    //show thumb
            
    @Header("Content-Type: image/".$this->img["format"]);

            
    /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
            
    $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
                @
    imagecopyresampled ($this->img["des"], $this->img["src"], 0000$this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);

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

        function 
    save($save="")
        {
            
    //save thumb
            
    if (empty($save)) $save=strtolower("./thumb.".$this->img["format"]);
            
    /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
            
    $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
                @
    imagecopyresampled ($this->img["des"], $this->img["src"], 0000$this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);

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



    ustteki kodu resize.txt olarak kayıt edin.

    kullanımı


     Kod Çizelgesi     Kod Dili: "php"
    <?
    include("resize.txt");                     //include class
    $thumb=new thumbnail("./shiegege.jpg");    // generate shiegege.jpg

    if ($_GET["size"]<50 || $_GET["size"]>500) {   // 50-500 pixels will resize
        
    echo "resize range 50 pixels - 500 pixels";    exit();
    }

    if (
    $_GET["mode"]=="height") {               // mode resize
        
    $thumb->size_height($_GET["size"]);
    } elseif (
    $_GET["mode"]=="width") {
        
    $thumb->size_width($_GET["size"]);
    } elseif (
    $_GET["mode"]=="auto" || empty($_GET["mode"])) {
        
    $thumb->size_auto($_GET["size"]);
    }

    $thumb->show();                            // show resize

    if ($_GET["save"]==1)                        // if save selected
        
    $thumb->save("./shiegege_thumb.jpg");
    ?> [/PHP]

    Bende bu şekilde kullanıyorum.

    [PHP]<?
    include("resize.txt");  
    $thumb=new thumbnail("./resim1.JPG");// Küçülecek resim
    $thumb->size_width(94);  // genişliği 94px yapar eğer aşağıdaki kod varsa bunu dikkate almaz
    $thumb->size_height(56); // yüksekliği 56px yapar eğer aşağıdaki kod varsa bunu dikkate almaz
    $thumb->size_auto(200); // genişliğini 200 yapıp orantılı olarak boyunuda kısaltır
    $thumb->jpeg_quality(75);// Resim kalitesi 75 önerilir 1 ile 100 arasında rakam girilir orjinalliğe göre
    $thumb->show();// göster demek :) Küçük resmi
    $thumb->save("./resim1_kucuk.jpg");    //küçülen resmin adı
    ?>




    Bu Kategoriye Ait Diğer Makaleler
    Başlık Tarih Hit
    PHP File Exists 2008-10-12 15:25:13 300
    PHP ile Bot Yapımı ve Sitelerden veri çekmek 2008-10-10 20:21:43 673
    Php ile Online sayac yapalim 2008-10-7 23:19:13 440
    Resim Yüklerken Küçük Resim Oluşturma Kodu 15/09/08 435
    php ile dosya upload ve veritabanına dosya ismini yazdırmak 15/09/08 383
    PHP ile Resim Üzderine Yazı Ekleme ve Kaydetme (anlatım) 13/09/08 360
    PHP’ye Namespace desteği 12/09/08 104
    PHP Podcastleri 12/09/08 172
    PHP 5.2 ile Dosya Yüklemelerini Takip Özelliği 12/09/08 198
    PHP & Json ve Twitter’dan Veri Çekmek 12/09/08 109
    Linke Gelince Değişen Resim (Javascript Rollover) 11/09/08 335
    Php ile Txt ziyaretçi sayaci yapalim 11/09/08 328
    HTML Dosyalarının İçine Php Kodlarını Ekleme 05/09/08 323
    PHP ile Resim Üzerine Yazı Ekleme ve Kaydetme 13/08/08 772
    Uzaktaki MySql a bağlanma? 08/08/08 508
    PHP ve PEAR Kullanımı 03/08/08 446
    Içeriklerimizi Koruyalim? 01/08/08 513
    PHP ile vBulletin Tarzı Sayfalama yapma 31/07/08 645
    php ile profesyonel sayfalama yapma 31/07/08 830
    Tarih Dönüşüm Fonksiyonu 25/07/08 409
    Dosya Kontrolleri 25/07/08 401
    PHP Zip Dosya Sıkıştırma Sınıfı (Class) 16/07/08 424
    İki defa aynı nickle üye olunmasını engellemek 09/07/08 587
    kelimeleri bölmek 03/07/08 431
    preg_match kullanımı 01/07/08 609

    Misafir - 2008-08-05 14:52:56
    tşk


    electro71 - 2008-08-10 01:00:02
    tşk


    Misafir - 2008-08-07 19:42:32
    tşkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

    Isminiz:
    E-mail adresiniz:
    Güvenlik Kodu:
      
     

     

    Görsel Dersler
  • Asp [59]

  • Asp.Net [5]

  • Csharp [33]

  • Delphi [85]

  • Delphi 7 [0]

  • Dreamweaver [45]

  • DW ile ASP Uygulamaları [28]

  • English Lessons [52]

  • Fireworks [4]

  • Flash [16]

  • HTML [20]

  • Java Script [0]

  • MS Access [19]

  • MS FrontPage [11]

  • Photoshop [32]

  • PHP [99]

  • Python [3]

  • SolidWorks [25]

  • Think Design [26]

  • VB Script [32]

  • Vb.Net [37]

  • Visual Basic [4]

  • iletisim    Reklam Verin Kadromuz Tavsiye Edin Site Haritasi Etiketler

    Sesli Chat beceri oyunlari

    Sitenizi Ekleyin.

    Sitemize Hosgeldiniz Sitemiz Genç Nesil Programlama Kaynak Sitesi Olup Siz Degerli Misafirlerimize Yararlanmaniz Amaci Ile Kurulmustur.



     

    Her hakki saklidir 2008 Tema : Pd - Ramazan
    Ferdi KÜÇÜK Web Stats webmaster forumu