Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-11-2004, 10:42 PM
YajivMalhotra's Avatar
Novice Webmaster
 
Join Date: Oct 2004
Location: Johor Bahru, Malaysia
Posts: 41
Rep Power: 0
YajivMalhotra is on a distinguished road
Send a message via Yahoo to YajivMalhotra
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2004, 09:39 AM
bazet's Avatar
Novice Webmaster
 
Join Date: Aug 2001
Location: Ampang KL
Posts: 93
Rep Power: 89
bazet is on a distinguished road
Send a message via ICQ to bazet Send a message via AIM to bazet Send a message via Yahoo to bazet
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ingin membuat sebuah laman web portal mengenai kawasan tempat tinggal. ikan_semilang Free Hosting Discussion Forum 12 28-05-2005 10:09 PM
@ Pekerja freelance(bebas) membuat website diperlukan daniel_kradmi Job Vacancies 15 06-10-2004 01:02 PM
url gambar asamad Website Design 20 03-10-2004 01:43 PM
Gambar & text dlm Flash MX lktt Website Design 2 17-09-2002 10:46 AM
animasi tulisan & gambar dwazni Website Design 7 19-06-2002 09:35 AM



All times are GMT +8. The time now is 05:27 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59