Jeg har forsøgt mig med noget imagedestroy(); men det ser ikke ud til at ændre noget.. Her er min resize kode:
$imagename = $_FILES['minfil']['name'];
$source = $_FILES['minfil']['tmp_name'];
$target = "images/kreationer/".$imagename;
move_uploaded_file($source, $target);
$imgext = strrchr($_FILES['minfil']['name'], ".");
$imagepath = $imagename;
//// CROP TIL MAX 800 PX
$save = "images/kreationer/".$gruppe_nr."_800px_".$imagepath; //This is the new file you saving
$file = "images/kreationer/".$imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
if ($width > 800) {
$modwidth = 800; } else {
$modwidth = $width; }
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
if ($imgext == ".png" || $imgext == ".PNG" ) {
$image = imagecreatefrompng($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagepng($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".jpg" || $imgext == ".JPG" || $imgext == ".jpeg" || $imgext == ".JPEG" ) {
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 90) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".gif" || $imgext == ".GIF" ) {
$image = imagecreatefromgif($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagegif($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}
//// CROP TIL MAX 400 PX
$save = "images/kreationer/".$gruppe_nr."_400px_".$imagepath; //This is the new file you saving
$file = "images/kreationer/".$imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
if ($width > 400) {
$modwidth = 400; } else {
$modwidth = $width; }
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
if ($imgext == ".png" || $imgext == ".PNG" ) {
$image = imagecreatefrompng($file) ;
imagealphablending($png, false);
imagesavealpha($png, true);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagepng($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".jpg" || $imgext == ".JPG" || $imgext == ".jpeg" || $imgext == ".JPEG" ) {
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 90) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".gif" || $imgext == ".GIF" ) {
$image = imagecreatefromgif($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagegif($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}
//// Resize TIL MAX 140 PX
$save = "images/kreationer/".$gruppe_nr."_140px_".$imagepath; //This is the new file you saving
$file = "images/kreationer/".$imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
if ($width >= $height) {
if ($width > 140) {
$modwidth = 140; } else {
$modwidth = $width; }
$diff = $width / $modwidth;
$modheight = $height / $diff;
} else {
if ($height > 140) {
$modheight = 140; } else {
$modheight = $height; }
$diff = $height / $modheight;
$modwidth = $width / $diff;
}
$tn = imagecreatetruecolor($modwidth, $modheight) ;
if ($imgext == ".png" || $imgext == ".PNG" ) {
$image = imagecreatefrompng($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagepng($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".jpg" || $imgext == ".JPG" || $imgext == ".jpeg" || $imgext == ".JPEG" ) {
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 90) ;
imagedestroy($tn);
imagedestroy($save);
}
if ($imgext == ".gif" || $imgext == ".GIF" ) {
$image = imagecreatefromgif($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagegif($tn, $save, 5) ;
imagedestroy($tn);
imagedestroy($save);
}