Visa ett inlägg
Oläst 2004-08-27, 15:42 #9
affe_810221 affe_810221 är inte uppkopplad
Nykomling
 
Reg.datum: Jul 2004
Inlägg: 38
affe_810221 affe_810221 är inte uppkopplad
Nykomling
 
Reg.datum: Jul 2004
Inlägg: 38
Använder följande när jag laddar upp och skapar thumbnails på mina sajter.

//$filadress=lokal filadress
//$fotoid=filens namn

if(copy("$filadress","fotoarkiv/$fotoid.jpg")){ //om uppladdningen lyckas

// ändra storleken
$size = getimagesize ("fotoarkiv/$fotoid.jpg");
$ursprwidth=$size[0];
$ursprheight=$size[1];

//bredd>höjd
if($size[0]>$size[1] && $size[0]>410){
$size[1]=$size[1]*410/$size[0];
//size[0]=width
$size[0]=410;
}
elseif($size[1]>390){
$size[0]=$size[0]*390/$size[1];
$size[1]=390;
}

$src_img = imagecreatefromjpeg("fotoarkiv/$fotoid.jpg");
$dst_img = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $size[0], $size[1], $ursprwidth, $ursprheight);
imagejpeg($dst_img, "fotoarkiv/$fotoid.jpg", 75);

//slut ändra storlek

//skapa thumbnail

$size = getimagesize ("fotoarkiv/$fotoid.jpg");
$ursprwidth=$size[0];
$ursprheight=$size[1];
//bredd>höjd
if($size[0]>$size[1] && $size[0]>100){
$size[1]=$size[1]*100/$size[0];
//size[0]=width
$size[0]=100;
}
elseif($size[1]>100){
$size[0]=$size[0]*100/$size[1];
$size[1]=100;
}
//annars blir d ingen förändring av storleken

$src_img = imagecreatefromjpeg("fotoarkiv/$fotoid.jpg");
$dst_img = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $size[0], $size[1], $ursprwidth, $ursprheight);
imagejpeg($dst_img, "fotoarkiv/thumbnails/$fotoid.jpg", 75);

//slut skapa thumbnail

flush();
header("Location: fotoarkiv.php");

} //slut om uppladdningen lyckades
else{
mysql_query("delete from fotoarkiv where id='$nyttfotoid'");
echo "uppladdningen misslyckades";
}
affe_810221 är inte uppkopplad   Svara med citatSvara med citat