index.php 0100644 0001752 0001752 00000001347 10675500440 012171 0 ustar doctea doctea if ($nothumb=="true") { ?>
thumbs version
} else { ?>
click for no thumbs version
} ?>
Please don't link directly to any of these images from your lame myspace page.
See my mp3s of dj mixes and things i have collected or made
$ddir = opendir (".");
while (false !== ($file = readdir($ddir))) {
if ($file!=".." && $file!=".") {
print "";
if ($nothumb!="true" && (strstr ($file, ".JPG") || strstr ($file, ".jpg") || strstr ($file, ".gif"))) {
print "
";
}
print "";
print "" . htmlspecialchars ($file) . "
";
}
}
?>
ithumb.php 0100644 0001752 0001752 00000011167 10567014516 012357 0 ustar doctea doctea
/*
args
----
REQUIRED args:
img = filename
w = width
h = height
bg = background color (eg. bg=7F7F7F)
OPTIONAL args:
bw = create black and white image
sh = shadow color
bc = border color
border = border size in pixels
tc = true color (0 = no[default], 1 = yes, 2 = resize as truecolor, convert to palette)
EXAMPLES:
http://moo.com/ithumb?img=foo.png&w=100&h=80&border=0&tc=2&bg=000000
http://moo.com/ithumb?img=images/foo.png&w=100&h=80&border=1&tc=2&bg=FFFFFF
*/
function thumb_AllocateHexColor($im, $hex)
{
return ImageColorAllocate($im,
hexdec(substr($hex, 0, 2)),
hexdec(substr($hex, 2, 2)),
hexdec(substr($hex, 4, 2)));
}
function thumb_ImageGreyscale($im)
{
for($pal=0;$pal 640) $w = 640;
if($h > 480) $h = 480;
if($border > 20) $border = 20;
if($border < 0) $border = 0;
if($bw && $tc == 1) $tc = 2; /* force 8 bit output for b/w images */
if(!eregi('^[0-9a-f]{6}$', $bg)) $bg = "000000"; //exit;
if(!empty($sh) && !eregi('^[0-9a-f]{6}$', $sh)) exit;
if($imgtype == "jpg") $imgtype = "jpeg";
$in_type = $imgtype;
$out_type = $imgtype;
if($tc == 2 || !function_exists("ImageGIF"))
$out_type = "png";
$cachefile = ".cache/" . str_replace("/", "_", $img).",$tc,$w,$h,$bg,$sh,$bc.$out_type";
/* do we have a cached version of this? */
if(file_exists($cachefile))
{
if(filectime($cachefile) >= filectime($img))
{
header("Content-type: image/$out_type");
readfile($cachefile);
exit;
}
/* we do but its out of date :( */
}
/* load source image / create destination image */
switch($in_type)
{
case "png": $src_im = ImageCreateFromPNG($img); break;
case "jpeg": $src_im = ImageCreateFromJPEG($img); break;
case "gif": $src_im = ImageCreateFromGIF($img); break;
}
$src_w = ImageSX($src_im);
$src_h = ImageSY($src_im);
if ((isset ($w) && !isset ($h)) || (isset ($h) && !isset ($w))) {
list($origw,$origh,$type,$attr) = getimagesize ($img);
if (!isset ($w)) { // height but no width
$ratio = $h / $origh;
$w = $origw * $ratio;
} else { // width but no height
$ratio = $w / $origw;
$h = $origh * $ratio;
}
}
$dst_w = $w - $border*2 - (empty($sh)?0:2);
$dst_h = $h - $border*2 - (empty($sh)?0:2);
if($tc)
{
$dst_im = ImageCreateTrueColor($w, $h);
}
else
{
$dst_im = ImageCreate($w, $h);
}
/* calculate size */
$ratio = $src_w/$src_h;
if($ratio > ($dst_w/$dst_h))
{
$add_h = $dst_h;
$dst_h = intval($dst_w / $ratio);
$add_h = ($add_h - $dst_h) / 2;
}
else
{
$add_w = $dst_w;
$dst_w = intval($dst_h * $ratio);
$add_w = ($add_w - $dst_w) / 2;
}
/* allocate background color */
//$bg_col = thumb_AllocateHexColor($dst_im, $bg);
//$bg_col = ImageColorAllocateAlpha($dst_im, 255, 255, 255, 127);
ImageAlphaBlending($dst_im, 0);
$bg_col = ImageColorAllocateAlpha($dst_im, 0, 0, 0, 127);
$bg_col = ImageColorTransparent($dst_im, $bg_col);
ImageSaveAlpha($dst_im, 1);
$out_type = "png";
if($tc)
{
ImageFilledRectangle($dst_im, 0, 0, $w-1, $h-1, $bg_col);
}
/* draw shadow */
if(!empty($sh))
{
$sh_col = thumb_AllocateHexColor($dst_im, $sh);
ImageFilledRectangle($dst_im, $add_w+$border+2, $add_h+$border+2,
$add_w+$border+$dst_w+1, $add_h+$border+$dst_h+1, $sh_col);
}
/* draw border */
if(!empty($bc))
{
$bc_col = thumb_AllocateHexColor($dst_im, $bc);
for($i=0; $border>$i; $i++)
ImageRectangle($dst_im, $i, $i, $w-$i-1, $h-$i-1, $bc_col);
}
/* resize */
if($tc)
{
ImageCopyResampled($dst_im, $src_im,
$add_w+$border, $add_h+$border, 0, 0,
$dst_w, $dst_h, $src_w, $src_h);
if($tc == 2)
ImageTrueColorToPalette($dst_im, 1, 255);
}
else
{
ImageCopyResized($dst_im, $src_im,
$add_w+$border, $add_h+$border, 0, 0,
$dst_w, $dst_h, $src_w, $src_h);
}
if($bw)
thumb_ImageGreyscale($dst_im);
/* save image */
switch($out_type)
{
case "png": ImagePNG($dst_im, $cachefile); break;
case "jpeg": ImageJPEG($dst_im, $cachefile); break;
case "gif": ImageGIF($dst_im, $cachefile); break;
}
header("Content-type: image/$out_type");
readfile($cachefile);
/* clean up */
ImageDestroy($src_im);
ImageDestroy($dst_im);
?>