Ändra imagecreatetruecolor till imagecreate samt ändra imagecopyresampled till imagecopyresized.
Frågan#1
Har det här skriptet som använder GD2. Slängde upp det på ett konto hos Citynetwork och upptäckte då att dom bara har GD1.
Någon som vet hur man gör om det så det funkar med GD1?
// Ladda upp ny bild
if ($_POST['fil'] == Ja){
$mapp = "../thumbs/";
$mapp2 = "../foton/";
// Ta bort STORA bokstäver
$_FILES["file"]["name"] = strtolower($_FILES["file"]["name"]);
// Ta bort mellanslag
$_FILES["file"]["name"] = str_replace(' ', '_', $_FILES["file"]["name"]);
// Ta bort å
$_FILES["file"]["name"] = str_replace('å', 'a', $_FILES["file"]["name"]);
// Ta bort ä
$_FILES["file"]["name"] = str_replace('ä', 'a', $_FILES["file"]["name"]);
// Ta bort ö
$_FILES["file"]["name"] = str_replace('ö', 'o', $_FILES["file"]["name"]);
if (file_exists($mapp.$_FILES['file']['name'])) {
header("location: galleri.php?Uppladdad=Kopia");
exit;
}
if(!empty($_FILES['file']['name'])) {
$file = $_FILES['file'];
$storlek = getimagesize($_FILES['file']['tmp_name']);
$nybredd = 90;
$nyhojd = 90;
$nybredd2 = 600;
$nyhojd2 = 600;
// kolla filändelsen
$filandelse = explode('.',$file['name']);
$sort = count($filandelse) - 1;
$so = $filandelse[$sort];
// tillåtna filtyper
if ($so != 'jpg'){
// Fel filtyp
header("location: galleri.php?Uppladdad=Nej");
exit;
}
// skapa tumnagel
if (($storlek[0] - $nybredd) >= ($storlek[1] - $nyhojd)) {
$bildbredd = $nyhojd;
$bildhojd = ($nybredd/$storlek[0])*$storlek[1];
} else {
$bildhojd = $nyhojd;
$bildbredd = ($bildhojd/$storlek[1])*$storlek[0];
}
$bild_kalla = imagecreatefromjpeg($file['tmp_name']);
$bild_skapa = imagecreatetruecolor($bildbredd, $bildhojd);
imagecopyresampled ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
imagejpeg ($bild_skapa, $mapp.$file['name'], 100);
imagedestroy ($bild_skapa);
// skapa stor bild
if (($storlek[0] - $nybredd2) >= ($storlek[1] - $nyhojd2)) {
$bildbredd = $nyhojd2;
$bildhojd = ($nybredd2/$storlek[0])*$storlek[1];
} else {
$bildhojd = $nyhojd2;
$bildbredd = ($bildhojd/$storlek[1])*$storlek[0];
}
$bild_kalla = imagecreatefromjpeg($file['tmp_name']);
$bild_skapa = imagecreatetruecolor($bildbredd, $bildhojd);
imagecopyresampled ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
imagejpeg ($bild_skapa, $mapp2.$file['name'], 100);
imagedestroy ($bild_skapa);
header("Location: galleri.php?Uppladdad=Ja");
exit;
}
}
