Hallo zusammen
hab mir ein php zusammengebastelt (z.B. für Fotogalerien), dass mir grosse Bilder auf thumbnails verkleinert, um die ladezeit der Vorschauseite zu verkürzen. Nun habe ich aber ein jpeg-Bild auf A3-Grösse mit ca. 2MB, bei dem folgende Fehlermeldung erscheint:
hier die entsprechende Datei, um die Thumbnails herzustellen:
[code]<?php
if (isset($_GET[‘img’]) AND $_GET[‘img’] != ‘’)
{
$bilddatei = htmlspecialchars($_GET[‘img’]);
if (isset($_GET[‘quer_width’]) AND intval($_GET[‘quer_width’]))
{
$widthA = intval($_GET[‘quer_width’]);
}
else
{
die(‘Parameter Quer Width fehlt’);
}
if (isset($_GET[‘hoch_height’]) AND intval($_GET[‘hoch_height’]))
{
$heightA = intval($_GET[‘hoch_height’]);
}
else
{
die(‘Parameter Hoch Height fehlt’);
}
if (file_exists($bilddatei))
{
$imagetyp = getimagesize($bilddatei);
if ($imagetyp[2] == 1)
{
$imagedata = imagecreatefromgif($bilddatei);
$mimetype = “image/gif”;
}
if ($imagetyp[2] == 2)
{
$imagedata = imagecreatefromjpeg($bilddatei); // <== Zeile 37
$mimetype = “image/jpeg”;
}
if ($imagetyp[2] == 3)
{
$imagedata = imagecreatefrompng($bilddatei);
$mimetype = “image/png”;
}
$imgOld= $imagedata;
$imageInfo = getimagesize($bilddatei);
$width = $imageInfo[0];
$height = $imageInfo[1];
if($width >= $height)
{
if ($width > $widthA) // Bild nur verkleinern, nicht vergroessern
{
$scale = $widthA/$width;
$heightA = round($height * $scale);
$img = imagecreatetruecolor($widthA,$heightA);
imagecopyresampled($img, $imgOld, 0,0, 0,0, $widthA,$heightA, ImageSX($imgOld),ImageSY($imgOld));
}
else
{ $img = $imgOld; }
}
else
{
if ($height > $heightA) // Bild nur verkleinern, nicht vergroessern
{
$scale = $heightA/$height;
$widthA = round($width * $scale);
$img = ImageCreateTruecolor($widthA,$heightA);
ImageCopyResampled($img, $imgOld, 0,0, 0,0, $widthA,$heightA, ImageSX($imgOld),ImageSY($imgOld));
}
else
{ $img = $imgOld; }
}
header("Content-type: " . $mimetype);
if ($imagetyp[2] == 1)
{
imagegif($img);
imagedestroy($img);
}
if ($imagetyp[2] == 2)
{
imagejpeg($img,NULL,100);
imagedestroy($img);
}
if ($imagetyp[2] == 3)
{
imagepng($img);
imagedestroy($img);
}
}
else
{
echo(‘Datei existiert nicht’);
}
}
else
{
echo(‘Fehlender Parameter’);
}
?>[/code]
Das seltsame finde ich, dass der Speicher - wenn ich das richtig verstehe - auf 67MB eingestellt ist, aber die Datei, die ich verarbeiten möchte, nur 2MB gross ist.
Kann mir jemand erklären, wieso ich diesen Fehler erhalte…?
Vielen Dank schon mal
grüsse
samo