Hallo daar,
Ik ben bezig met een album site.
Nu heb ik een multi upload gevonden op het internet.
dit werkt allemaal heel goed.
Maar nu wil ik de foto verkleinen. Bij de thumbs werkt dit goed.
Maat wil ik verkleinen naar 600 Width of height.
Dan komt hij niet in de map.
<?php require_once "phpuploader/include_phpuploader.php" ?>
<?php
mysql_connect('localhost','Geb','ww');
mysql_select_db('data?_site');
$uploader=new PhpUploader();
$mvcfile=$uploader->GetValidatingFile();
if($mvcfile->FileName=="accord.bmp")
{
$uploader->WriteValidationError("My custom error : Invalid file name. ");
exit(200);
}
//USER CODE:
$targetfilepath= "../fotos/".$_GET['map'] ."/". $mvcfile->FileName;
mysql_query("INSERT INTO pictures (cat,foto) VALUES ('".$_GET['id']."','".$mvcfile->FileName."')");
if( is_file ($targetfilepath) )
unlink($targetfilepath);
$mvcfile->MoveTo( $targetfilepath );
$uploader->WriteValidationOK();
$url = "../fotos/".$_GET['map']."/".$mvcfile->FileName;
$pic = @imagecreatefromjpeg($url) or die ("Image not found!");
if ($pic) {
$width = imagesx($pic);
$height = imagesy($pic);
if($width > $height)
{
$twidth = "140"; # width of the thumb 160 pixel
$theight = $twidth * $height / $width; # calculate height\
}
else
{
$theight = "140"; # calculate height\
$twidth = $theight * $width / $height; # width of the thumb 160 pixel
}
$thumb = @imagecreatetruecolor ($twidth, $theight) or
die ("Can't create Image!");
imagecopyresized($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width, $height); # resize image into thumb
imagejpeg($thumb, '../fotos/thumb/'.$_GET['map'].'/'. $mvcfile->FileName); # Thumbnail as JPEG
imagedestroy($thumb);
}
$show = @imagecreatefromjpeg($url) or die ("Image not found!");
if ($show) {
$s_width = imagesx($show);
$s_height = imagesy($show);
if($s_width > $s_height)
{
$swidth = "600"; # width of the thumb 160 pixel
$sheight = $swidth * $s_height / $s_width; # calculate height\
}
else
{
$sheight = "600"; # calculate height\
$swidth = $sheight * $s_width / $hs_eight; # width of the thumb 160 pixel
}
$show2 = @imagecreatetruecolor ($swidth, $sheight) or
die ("Can't create Image!");
imagecopyresized($show2, $pic, 0, 0, 0, 0, $swidth, $sheight, $s_width, $s_height); # resize image into thumb
imagejpeg($show2, '../fotos/show/'.$_GET['map'].'/'. $mvcfile->FileName); # Thumbnail as JPEG
imagedestroy($show2);
}
?>
iemand een idee ?
Bedankt alvast :D
1.175 views