Bild erzeugen
Goodies
- php
0 Snucky
Hi,
hab mir ein kleines script gebaut.
<?php
$art = $_GET["art"];
header ("Content-type: image/jpg");
$file = "../../UserFiles/Image/bilder/$art.jpg";
$copy = "Hallo";
$textx = "70";
$texty = "95";
$width = 240;
$height = 205;
$scource = imagecreatefromjpeg($file);
$destination = imagecreate($width, $height);
$white = imagecolorallocate($destination, 255, 255, 255);
imagecopyresized($destination, $scource, 0, 0, 0, 0, $width, $height, imagesx($scource), imagesy($scource));
imagestring($destination, 0, $textx, $texty, $copy, $white);
imagejpeg($destination);
imagedestroy($destination);
?>
Das Bild zeigt er sehr mit einer sehr schlechten qualität an.
http://www.schluffti.com/Shop/admin_admin/bildbearbeitung.php?art=102717
Hier das Original
http://www.schluffti.com/UserFiles/Image/bilder/102717.jpg
Wie kann ich die Qualität verbessern??
danke
mfg
Goodies
Das Bild zeigt er sehr mit einer sehr schlechten qualität an.
http://www.schluffti.com/Shop/admin_admin/bildbearbeitung.php?art=102717
Hier das Original
http://www.schluffti.com/UserFiles/Image/bilder/102717.jpgWie kann ich die Qualität verbessern??
Den genauen Grund kann ich dir nicht erläutern, obwohl ich darüber schon gelesen habe - es lässt sich also Information finden. Du nutzt die falsche Funktion zum Erzeugen und Ausschneiden. Besser sind imagecreatetruecolor und imagecopyresampled.
Hier, dieses war im Manual yu finden:
Note: There is a problem due to palette image limitations (255+1 colors). Resampling or filtering an image commonly needs more colors than 255, a kind of approximation is used to calculate the new resampled pixel and its color. With a palette image we try to allocate a new color, if that failed, we choose the closest (in theory) computed color. This is not always the closest visual color. That may produce a weird result, like blank (or visually blank) images. To skip this problem, please use a truecolor image as a destination image, such as one created by imagecreatetruecolor().
Bei Interesse schick' ich dir meine Klasse, die Dateiuploads verwaltet und mitunter auch sehr angenehm Thumbnails generiert.