This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

My optimized thumb.php


avatar
Keiretsu 0
From: -
My optimized thumb.php

Hey dude,
This is my thumb.php, if you need it..

Updates:
-Better image quality
-All thumbnail are in max 150x150 size (can be edited)

<?php


/*
############################################################################
# #
# Esselbach Storyteller CMS System #
# Limited freeware version for evaluation purpose #
# #
# (C) 2002 - 2005 by Esselbach Internet Solutions #
# Available from  http://www.esselbach.com #
# #
# Visit  http://www.esselbach.com/page6.html for the license agreement #
# #
############################################################################
*/

require("core.php");

if (phpversion() >= "4.1.0")
{
$img = $_GET["img"];
$action = $_GET["action"];
$section = $_GET["section"];
}

if (!$section)
{
$section = "review";
}

if (!preg_match("/review|news|faq|downloads/i",$section)) exit;
if ((preg_match("///i", $img)) or (preg_match("///i", $section))) exit;

if ($action == "full")
{
$insert[thumb] = "images/$section/$img";
echo GetTemplate("site_thumb");
exit;
}

if (file_exists("images/$section/thumbs/$img"))
{
header("Location: images/$section/thumbs/$img");
}

$imgdat = explode(".", $img);

if ($imgdat[1] == "png")
{
header("Content-type: image/png");
$source = imagecreatefrompng("images/$section/$img");
}

if ($imgdat[1] == "gif")
{
header("Content-type: image/gif");
$source = imagecreatefromgif("images/$section/$img");
}

if (($imgdat[1] == "jpeg") or ($imgdat[1] == "jpg"))
{
header("Content-type: image/jpeg");
$source = imagecreatefromjpeg("images/$section/$img");
}

if (!$configs[13])
{
$configs[13] = 3;
}

$size = getimagesize("images/$section/$img");

// edit this
$l = 150;
// edit this

if( $size[0]>$l or $size[1]>$l ){
$centerX = $size[0]/2;
$centerY = $size[1]/2;
if( $size[0] > $size[1] ){
$luy = 0;
$lux = $centerX-$centerY;
$rdy = $size[1];
$rdx = $size[1];
}
else{
$lux = 0;
$luy = $centerY-$centerX;
$rdx = $size[0];
$rdy = $size[0];
}
$thumb = imagecreatetruecolor($l, $l);
imagecopyresampled($thumb, $source, 0, 0, $lux, $luy, $l, $l, $rdx, $rdy);
} else {
$thumb == "images/$section/$img";
}

@imagedestroy($source);

if ($imgdat[1] == "png")
{
imagepng($thumb, "images/$section/thumbs/$img");
@chmod ("images/$section/thumbs/$img", 0777);
}
if ($imgdat[1] == "gif")
{
imagegif($thumb, "images/$section/thumbs/$img");
@chmod ("images/$section/thumbs/$img", 0777);
}
if (($imgdat[1] == "jpg") or ($imgdat[1] == "jpeg"))
{
imagejpeg($thumb, "images/$section/thumbs/$img");
@chmod ("images/$section/thumbs/$img", 0777);
}

if (file_exists("images/$section/thumbs/$img"))
{
header("Location: images/$section/thumbs/$img");
}

?>

Smiling Face

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.