<?php
require_once("phpPhotoGallery.php");
class myThumbnails extends myPhotoGallery
{
//1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order),
//8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
var $indImage;
var $typeImage;
var $scaleImage;
var $task;
function myThumbnails ($imageName, $task, $typeImage ,$scaleImage)
{
$this->addImageName($imageName);
$this->indImage = 0;
$this->typeImage = $typeImage;
$this->scaleImage = $scaleImage;
$this->task = $task;
}
function createThumbnails ($widthImage, $heightImage)
{
if ($this->gallery[$this->indImage][3] == 1)
$im = @imagecreatefromgif($this->gallery[$this->indImage][0]);
else if ($this->gallery[$this->indImage][3] == 2)
$im = @imagecreatefromjpeg($this->gallery[$this->indImage][0]);
else if ($this->gallery[$this->indImage][3] == 3)
$im = @imagecreatefrompng($this->gallery[$this->indImage][0]);
if($this->gallery[$this->indImage][3] != 1)
{
$new = @imagecreatetruecolor($widthImage, $heightImage);
@imagecopyresampled($new, $im, 0, 0, 0, 0, $widthImage, $heightImage, $this->gallery[$this->indImage][1], $this->gallery[$this->indImage][2]);
}
else
{
$new = @imagecreate($widthImage, $heightImage);
@imagecopyresized($new, $im, 0, 0, 0, 0, $widthImage, $heightImage, $this->gallery[$this->indImage][1], $this->gallery[$this->indImage][2]);
}
@imagedestroy($im);
return($new);
}
function viewThumbnails ($imageResource)
{
header('Content-Type: ' . $this->gallery[$this->indImage][3]['mime']);
if ($this->gallery[$this->indImage][3] == 2)
imagejpeg($imageResource, '', 100);
else if ($this->gallery[$this->indImage][3] == 1)
imagegif($imageResource);
else if ($this->gallery[$this->indImage][3] == 3)
imagepng($imageResource);
}
function processImage ()
{
list($widthImage, $heightImage) = $this->getDimImage($this->indImage, $this->typeImage, $this->scaleImage);
if ($this->task == "Thumbnails")
{
$imageResource = $this->createThumbnails($widthImage, $heightImage);
$this->viewThumbnails($imageResource);
}
else if ($this->task == "Image")
{
header ("cache-control: no-cache, must-revalidate");
header ("pragma: no-cache");
print '<html>
<title></title>
<head>
</head>
<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<center><img src="' . $this->gallery[$this->indImage][0] . '" width="' . $widthImage . '" height="' . $heightImage . '" border="0"></center>
</body>
</html>';
}
}
}
$thumbnail = new myThumbnails($_GET["imagename"], $_GET["task"], $_GET["typeImage"], $_GET["scaleImage"]);
$thumbnail->processImage();
?>