habe hier ein problem beim verkleinern von bildern.
habe mir ein script zum testen geschrieben. das funktioniert auch schon halbwegs gut, nur ist das bild hinterher schwarz. die neue größe stimmt jedoch.
hier das script.
- Code: Select all
<?
if (!isset($oldpic))
{
?>
<html>
<body>
<form action="img_resize.php?action=check" METHOD="POST">
<input type="file" name="oldpic" style="widht:300px;"><br>
<input type="text" name="oldpic" style="width:300px;"><br>
<input type="submit" value="absenden"><br>
</form>
</body>
</html>
<?
}
if ($action=="check")
{
$oldpicture = "../images/galerie/". $_POST['oldpic'];
//$oldpicture = $_POST['oldpic'];
$imgsize_old = getimagesize($oldpicture);
$owidth = $imgsize_old[0];
$oheight = $imgsize_old[1];
$nwidth = "300";
$nheight = round(($nwidth*$oheight)/$owidth);
echo "alte Breite: ". $owidth ." | alte Höhe: ". $oheight ."<br>";
echo "neue Breite: ". $nwidth ." | neue Höhe: ". $nheight;
?>
<table style="border:1px solid #efefef;" width="<? echo $nwidth; ?>" height="<? echo $nheight; ?>">
<tr>
<td width=<? echo $nwidht; ?> height=<? echo nheight; ?> bgcolor="#dedede"> </td>
</tr>
</table>
<?
//$npic = imagecreate($nwidth, $nheight);
//$newpic = imagecreatetruecolor($nwidth, $nheight) or die("Cannot Initialize new GD image stream");
//imagepalettecopy ($newpic,$oldpicture);
//imagecopyresampled ($newpic, $oldpicture, 0, 0, 0, 0, $nwidth, $nheight, $owidth, $oheight);
//imagejpeg($newpic , "../images/galerie/resize_". $_POST['oldpic'], 100);
//imagejpeg($newpic , "resize_". $oldpicture, 100);
//imagedestroy($newpic);
$dest = imagecreatetruecolor($nwidth, $nheight);
imageantialias($dest, TRUE);
$src = imagecreatefromjpeg($oldpicture);
imagecopyresampled($dest, $src, 0, 0, 0, 0, $nwidth, $nheight, $size[0], $size[1]);
imagejpeg($dest,"../images/galerie/resize_". $_POST['oldpic'], 100);
imagedestroy($dest);
}
kann mir da jemand weiterhelfen, der vielleicht auch schonmal ein solches problem gehabt hat ?
Thx,
HENNER