W sumie nie zauważyłem że mi odpisałeś ale sam też doszedłem dzięki Twoim podpowiedziom i coś takiego mi wyszło.
// udostępnienie zmiennych
$img_nazwa = $_POST['img_nazwa'];
$img_fot = "fot/";
$img_min = "fot/min/";
$image_tempname = $_FILES['image_filename']['name'];
$img_kat = $_POST['kategorie'];
// umieszczenie obrazu i sprawdzenie jego formatu
$ImageDir = "fot/";
// folder minaturek
$ImageThumb = $ImageDir . "min/";
$ImageName = $ImageDir . $image_tempname;
$ImageName)) {
// pobranie informacji na temat umieszczonego obrazu
list
($width, $height, $type, $attr) = getimagesize($ImageName);
if ($type > 3) {
echo "Przykro nam, ale przesłany obraz nie jest w formacie GIF, JPG lub " . "PNG.<br>";
echo "Kliknij przycisk 'Wstecz' w przeglądarce i spróbuj ponownie."; } else {
// wstawienie informacji w tabeli images
$insert = "INSERT INTO img
(img_nazwa, img_date, img_fot, img_min,img_kat)
VALUES
('$img_nazwa', '$today', '$img_fot', '$img_min', '$img_kat')";
$newfilename = $ImageDir . $lastpicid . ".jpg";
if ($type == 2) {
$max_width = 1024;
$max_height = 1024;
$new_width = $max_width;
$ratio = $max_width / $width;
$new_height = $height * $ratio;
rename($ImageName, $newfilename); $image = imagecreatefromjpeg($newfilename);
$imagenew = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($imagenew, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($imagenew, $newfilename);
imagedestroy($image);
imagedestroy($imagenew);
} else {
if ($type == 1) {
$image_old = imagecreatefromgif($ImageName);
} elseif ($type == 3) {
$image_old = imagecreatefrompng($ImageName);
}
$max_width = 1024;
$max_height = 1024;
$new_width = $max_width;
$ratio = $max_width / $width;
$new_height = $height * $ratio;
$image_jpg = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_jpg, $newfilename);
imagedestroy($image_old);
imagedestroy($image_jpg);
}
$newthumbname = $ImageThumb . $lastpicid . ".jpg";
$max_width = 1024;
$max_height = 1024;
$new_width = $max_width;
$ratio = $max_width / $width;
$new_height = $height * $ratio;
// pobierz wymiary miniaturki
$thumb_width = $new_width * 0.10;
$thumb_height = $new_height * 0.10;
// utwórz miniaturkę
$largeimage = imagecreatefromjpeg($newfilename);
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0,
$thumb_width, $thumb_height, $new_width, $new_height);
imagejpeg($thumb, $newthumbname);
imagedestroy($largeimage);
imagedestroy($thumb);
}
}
?>
Wielkie dzieki Za pomoc
Ten post edytował goofynow 30.03.2012, 13:12:28