Results 1 to 2 of 2

Thread: Tutorial: Membuat Gambar Thumbnail

  1. #1
    Join Date
    Oct 2004
    Location
    Johor Bahru, Malaysia
    Posts
    41
    Rep Power
    0

    Tutorial: Membuat Gambar Thumbnail

    recently aku surf 1 site... jumpa la.. script simple ni.... untuk create thumbnail image ... script untuk membantu sesapa yang nak buat gallery simple ker.. apa apa la...

    Fungsi Script:-

    mengambil gambar asal (pelbagai size) .dari directory.. dan save sebagai gambar thumbnail di directory baru. Size boleh ditentukan sendiri.



    <?php
    $thumb_dir = "thumb"; // directory nak letak thumbnail image
    $dh = opendir("."); // directory gambar asal

    while ($f = readdir( $dh ) ) {
    echo call_user_func ('makethumb', $f);
    }

    function makethumb($file)
    {

    if(eregi("\.(jpg|jpeg)$",$file))
    if (!file_exists("$thumb_dir/$file")) { //is it there already? Lets check & find out...
    $src = ImageCreateFromJPEG($file);

    $filesize = filesize($file);
    $org_h = imagesy($src);
    $org_w = imagesx($src);

    print "Original Size (<b>W</b>x<b>H</b>): <b>$org_w</b>x<b>$org_h</b> &gt;&gt; ";

    if ($org_h > $org_w) {
    $height = 72; // size thumbnail (panjang x lebar $width = floor ($height * $org_w / $org_h);
    } else {
    $width = 96;
    $height = floor ($width * $org_h / $org_w);
    }

    $img = ImageCreate($width,$height);

    ImageCopyResized ($img, $src, 0, 0, 0, 0, $width, $height, $org_w, $org_h );

    ImageJPEG($img, "$thumb_dir/$file", 75);
    print "The file <b>$file</b> has been copied and resized.<br>";

    ImageDestroy ($img);
    ImageDestroy ($src);
    } else print "The file <b>$file</b> exists already.<br>";

    }
    ?>



    contoh lain... http://www.weberdev.com/get_example-4032.html
    Last edited by YajivMalhotra; 01-11-2004 at 10:45 PM.

  2. #2
    Join Date
    Aug 2001
    Location
    Ampang KL
    Posts
    93
    Rep Power
    219
    Good info.

    Style aku pulak

    Baca actual file
    PHp auto generate thumb on the fly ikut parameter yg diberi guna $_GET,tapi resource hunger laa method aku nih.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. @ Pekerja freelance(bebas) membuat website diperlukan
    By daniel_kradmi in forum Job Vacancies
    Replies: 16
    Last Post: 11-12-2009, 09:59 AM
  2. masalah membuat client server (pembetulan)
    By healboy in forum Website Design
    Replies: 0
    Last Post: 06-09-2007, 06:09 PM
  3. url gambar
    By asamad in forum Website Design
    Replies: 20
    Last Post: 03-10-2004, 01:43 PM
  4. Gambar & text dlm Flash MX
    By lktt in forum Website Design
    Replies: 2
    Last Post: 17-09-2002, 10:46 AM
  5. animasi tulisan & gambar
    By dwazni in forum Website Design
    Replies: 7
    Last Post: 19-06-2002, 09:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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 29 30 31 32 33 34 35 36 37 38 39