Forstår ikke mekanikken i billed behandling - imagecreatefromjpeg
Der er upload af et billede via form, og herfra $enfil.Update af database med filnavn og fil gemt i mappe går fint - copy($enfil, "path").
I en php bog har jeg følgende skript til billed resize. Men der kommer kun krims krams tekststreng...
$image erstattet med min $enfil
if (!$max_width)
$max_width = 80;
if (!$max_height)
$max_height = 60;
$size = GetImageSize($enfil);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg($enfil);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
// header("Content-type: image/jpeg"); // se nedenfor...
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
Header image/jpeg er sat øverst, men kan man det samtidig med text/html:
<META http-equiv=content-type content=text/html; content=image/jpeg; charset=iso-8859-1> ??
Og linien
ImageJpeg($dst, null, -1);
giver som sagt kun en tekststreng, ikke noget billede.
Hvad er der galt?
