thumbnail how to

This is a discussion on thumbnail how to within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I am looking for an easy to use thumbnail php script. I googled arround but cannot find one, or ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-27-2005
Bruintje Beer
 
Posts: n/a
Default thumbnail how to

Hi,

I am looking for an easy to use thumbnail php script. I googled arround but
cannot find one, or maybe my search is not so good :)

John


Reply With Quote
  #2 (permalink)  
Old 11-27-2005
Geoff Berrow
 
Posts: n/a
Default Re: thumbnail how to

Message-ID: <438948b6$0$711$5fc3050@dreader2.news.tiscali.nl > from
Bruintje Beer contained the following:

>Hi,
>
>I am looking for an easy to use thumbnail php script. I googled arround but
>cannot find one, or maybe my search is not so good :)
>

Here's a simple one. You load your .jpg files and this script to a
directory. Then you create a subdirectory called thumbs and chmod it to
777. Run the script and on the first pass it creates thumbnail images
in the subdirectory. Subsequent viewings use the stored images.



<HTML>
<HEAD>
<TITLE>Contact sheet</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<style>
..image{width:114px;text-align:center;margin:4px}
img{border: 0px; margin:auto;}
</style
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<div style="text-align:center">
<div style="margin:auto">


<?php

$path=$_SERVER['SCRIPT_FILENAME'];
$dir=dirname($path);


$thumbpath = "thumbs/";
$height=75;
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//print $dir . $file;
if($file!="." && $file!=".." &&
strtolower(substr($file,-3))=="jpg"){
$filepath=$thumbpath."s_".$file;
if(!file_exists($filepath)){
if($src_img =
@imagecreatefromjpeg($file)){
$new_h = $height;
$size=getimagesize($file);
$new_w = ($new_h*$size[0])/$size[1];
$dst_img =
imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img, $src_img,
0, 0, 0, 0, $new_w, $new_h, $size[0], $size[1]);
imagejpeg($dst_img, $filepath, 100);
$alt=$file;
}
else{
$alt="Bad jpg!";
}

}
else{
$alt=$file;
}



echo "<span class='image'><a href=\"$file\"><img
src='".$filepath."'alt='$alt'></a></span>\n";
}
}
closedir($dh);
}

?>

</div>
</div>

</BODY>
</HTML>

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:19 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0