Hey,
wij (willen) gebruiken op onze (toekomstige) site deze klasse om foto's te verkleinen en thumbs aan te maken. Maar driemaal helaas, het werkt nàtuurlijk weer niet. Op mijne localhost werkt het nochtans wel... Als ik het script uitvoer, krijg ik wel de vermelding "gelukt", maar de nieuwe foto wordt niet aangemaakt.
In de map 'test' staat: test.php en image.class.php
Welke permissie moet de map test krijgen? 777? of is dat niet nodig (in beide gevallen werkt het niet...)
Geraakt er iemand wijs uit waarom het niet werkt? Hartelijken dank alvast
test.php
Code:
include("image.class.php");
$source = "F10.jpg";
$max_width = "500";
$max_height = "500";
$dest = "F11.jpg";
$obj = new image;
$obj->display($source,$max_width,$max_height,$dest);
image.class.php
Code:
class image {
var $source;
var $max_width;
var $max_height;
var $dest;
function display($source,$max_width,$max_height,$dest)
{
$this->max_width = $max_width;
$this->max_height = $max_height;
$this->source = $source;
$this->dest = $dest;
$this->create();
}
function get_width()
{
$img_info = getimagesize($this->source,$info);
return $img_info[0];
}
function get_height()
{
$img_info = getimagesize($this->source,$info);
return $img_info[1];
}
function get_extension()
{
$img_info = getimagesize($this->source,$info);
if ($img_info[2]==1) {
return "gif";
} elseif ($img_info[2]==2) {
return "jpg";
} elseif ($img_info[2]==3) {
return "png";
} else {
$return = 0;
}
}
// Width calculation of thumbnail
function CalcWidth()
{
if ($this->get_width() > $this->get_height()) {
//
// let's take the width as the largest dimension
//
return ($this->max_width);
} else {
//
// the width will have to be of the same ration as the height
//
return(floor(($this->max_height * $this->get_width()) / $this->get_height()));
}
}
// Height calculation of thumbnail
function CalcHeight()
{
if ($this->get_width() > $this->get_height()) {
//
// the height will have to be of the same ration as the width
//
return(floor(($this->max_width * $this->get_height()) / $this->get_width()));
} else {
//
// let's take the height as the largest dimension
//
return($this->max_height);
}
}
// Creating a thumbnail
function Create()
{
switch ($this->get_extension())
{
case 'gif':
$img_src = ImageCreateFromGIF ( $this->source );
break;
case 'jpg':
$img_src = imagecreatefromjpeg ( $this->source );
break;
case 'png':
$img_src = ImageCreateFromPNG ( $this->source );
break;
}
$img_des = imagecreatetruecolor($this->CalcWidth(), $this->CalcHeight());
if(!file_exists($this->dest)) {
imagecopyresized($img_des, $img_src, 0, 0, 0, 0, $this->CalcWidth(), $this->CalcHeight(), $this->get_width(), $this->get_height());
imagejpeg($img_des,$this->dest);
echo "gelukt";
} else {
echo "Foto bestaat al<br />";
$continue = FALSE;
}
}
}