PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Problem mit Grafikprogrammierung


Tuxman
04.12.2007, 09:16:02
Serwas,

folgendes Problem:

Ich bin gerade dabei, ein kleines Projekt (http://derklapper.de.funpic.de/projekt/) zu entwerfen. Nun geht es OHNE die Auswahl eines hochgeladenen Bildes fehlerfrei, weigert sich aber leider permanent, ein eingebundenes (hochgeladenes) Bild einzublenden:
Die Grafik "http://derklapper.de.funpic.de/projekt/blogpic.php?rand=0.4838817999733185&bgcol1=00ff00&bgcol2=0000ff&fgcol=ff8000&text=testbild&fontsize=2&imgFile=files/953f5cc8c4122c2eae1b95c10c0a7ea8.jpg" kann nicht angezeigt werden, weil sie Fehler enthält.

Der Code im Detail:
<?php
// pass variables
$text = $_GET['text'];
$bgcol1 = $_GET['bgcol1'];
$bgcol2 = $_GET['bgcol2'];
$fgcol = $_GET['fgcol'];
$fontsize = $_GET['fontsize'];
$imgFile = $_GET['imgFile'];

// create the basic image (120x32)
$img = imagecreatetruecolor(120, 32) or die("The GD library could not be accessed here... too bad!");

// === left frame ===
// convert HTML color code to RGB values
$tmpBgCol = imagecolorallocate($img, hexdec('0x' . $bgcol1{0} . $bgcol1{1}), hexdec('0x' . $bgcol1{2} . $bgcol1{3}), hexdec('0x' . $bgcol1{4} . $bgcol1{5}));
// draw a square, depending on the size of the image (keep an 1px border)
imagefilledrectangle($img, 1, 1, imagesy($img)-2, imagesy($img)-2, $tmpBgCol);

// has an image been uploaded?
if ($imgFile) {
// so now we have a file "something.jpg" in the subdir "files", but we need the absolute path...
// (http://<server>/<path>/<file>)
$imgFile = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "/../" . $imgFile;
// check the image file's extension, as we need to use filetype-based import functions...
$imgFileExt = strrchr(strtolower($imgFile), ".");
$imgInput = ( $imgFileExt == ".jpg" || $imgFileExt == ".jpeg" ? imagecreatefromjpeg($imgFile) : ( $imgFileExt == ".png" ? imagecreatefrompng($imgFile) : ( $imgFileExt == ".gif" ? imagecreatefromgif($imgFile) : "" ) ) );
if (!empty($imgInput)) { // only if a valid file type was detected
// copy the source image into our new one, but resample it to a square
// (height = width = our image's height - 2 to keep the 1px border)
list($width, $height) = getimagesize($imgFile);
imagecopyresampled($img, $imgInput, 1, 1, 0, 0, imagesx($img)-2, imagesy($img)-2, $width, $height);
}
}

// === right frame ===
// draw background image
// -- convert HTML color code to RGB values
$tmpBgCol = imagecolorallocate($img, hexdec('0x' . $bgcol2{0} . $bgcol2{1}), hexdec('0x' . $bgcol2{2} . $bgcol2{3}), hexdec('0x' . $bgcol2{4} . $bgcol2{5}));
// -- draw a rect, depending on the size of the image (keep an 1px border)
imagefilledrectangle($img, imagesy($img), 1, imagesx($img)-2, imagesy($img)-2, $tmpBgCol);

// draw text
// -- convert HTML color code to RGB values
$tmpFgCol = imagecolorallocate($img, hexdec('0x' . $fgcol{0} . $fgcol{1}), hexdec('0x' . $fgcol{2} . $fgcol{3}), hexdec('0x' . $fgcol{4} . $fgcol{5}));
// -- check string size in order to place it correctly
$text_x = imagesx($img) - imagefontwidth($fontsize) * strlen($text) - 3; // 3px from right edge
$text_y = imagesy($img) - imagefontheight($fontsize) - 3; // 3px from bottom edge
// -- draw the text
imagestring($img, $fontsize, $text_x, $text_y, $text, $tmpFgCol);

// === send HTTP headers ===
header("Expires: Thu, 01 Apr 2004 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Pragma: no-cache");
header("Content-type: image/png");

// === show and destroy the image ===
imagepng($img);
imagedestroy($img);
?>
Wo ist der Fehler?

CIX88
04.12.2007, 10:48:36
Gibt es eine Fehlermeldung ?

Tuxman
04.12.2007, 10:59:56
Nur die, die ich oben zitierte. :(
Das isses ja.

(Und auch die nur, wenn ich die blogpic.php separat aufrufe; wenn ich sie als Bild einbinde, natürlich nicht.)


edit:
Auf meinem lokalen Server (Apache/WinXP) geht alles fehlerfrei. Rechteproblem evtl.?