• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Thumbnail Klasse

Status
Für weitere Antworten geschlossen.

CrackPod

Neues Mitglied
Also mein Quellcode sieht wie folgt aus:
klassen.php
[php:1:22edb8ced4]<?php
error_reporting(E_ALL);
class Bilder {
var $bildbreite;
var $bildhoehe;
var $bildtyp;
var $bildname;
function Bilder($bild) {
$this->bildname = $bild;
$bildGroese = getimagesize($bild);
$this->bildbreite = $bildGroese[0];
$this->bildhoehe = $bildGroese[1];
$this->bildtyp = $bildGroese[2];
}
function thumbnailCreate($maxbreite,$maxhoehe) {
if($this->bildtyp == 1) {
$image = imagecreatefromgif($this->bildname);
header("Content-type: image/gif");
}
elseif($this->bildtyp == 2) {
$image = imagecreatefromjpeg($this->bildname);
header("Content-type: image/jpeg");
}
elseif($this->bildtyp == 3) {
$image = imagecreatefrompng($this->bildname);
header("Content-type: image/png");
}
$breite = imagesx($image);
$hoehe = imagesy($image);
if($this->bildbreite > $maxbreite)
$this->bildbreite = $maxbreite;
if($this->bildhoehe > $maxhoehe)
$this->bildhoehe = $maxhoehe;
$thumbnail = imagecreatetruecolor($this->bildbreite,$this->bildhoehe);
imagecopyresized($thumbnail,$image,0,0,0,0,$this->bildbreite,$this->bildhoehe,$breite,$hoehe);
if($this->bildtyp == 1)
imagegif($thumbnail);
elseif($this->bildtyp == 2)
imagejpeg($thumbnail,'./tmp/',80);
elseif($this->bildtyp == 3)
imagepng($thumbnail);
imagedestroy($image);
imagedestroy($thumbnail);
}
}
?>[/php:1:22edb8ced4]
klassen-test.php
[php:1:22edb8ced4]<?php
<?php
include("klassen.php");
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<h2>Thumbnail Test</h2>
<?php
$bild = "forum_normal.png";
$thumbnails = new Bilder($bild);
echo 'Das Bild '.$bild.' hat die Maße: '.$thumbnails->bildbreite.'px * '.$thumbnails->bildhoehe.'px
Preview:';
$thumbnails->thumbnailCreate(100,200);
?>
Hallo wie gehts so?
</body>
</html>
?>[/php:1:22edb8ced4]
So jetz bekomm ich entweder meinen Text inclusive wirrem Zeichensalat, da das Bild als Text ausgegeben wird, oder ich bekomm mein Thumbnail allerdings ohne Text...

Jetz meine Frage:
Wie bekomme ich beide?
Muss ich da nen besonderen Header senden oder wie geht das?
 
Werbung:
du kannst nicht in einer php-datei html-code und ein bild an den browser schicken. dazu brauchst du zwei requests, also einen für den html-code mit einem
tag, und den anderen um das bild auszugeben. die src von dem img-tag sollte dann halt auf ein entsprechendes php-skript verweisen, das das bild ausgibt.

die fürs bild nötigen header findest du hier: http://www.php.net/manual/de/function.imagegif.php
 
Werbung:
kannst du mir das bitte posten wie das dann aussehen muss??

ich bekomm es nicht hin mit dem img tag es kommt immer dasselbe

egal ob [php:1:76bef5c297]<?php
echo '
';
?>[/php:1:76bef5c297]
oder
[php:1:76bef5c297]<?php
echo '<img src="';
$thumbnails->thumbnailCreate(100,30)
echo ">';
?>[/php:1:76bef5c297]

Immer der blöde zeichensalat
 
xy.html:
Code:
<html>
<head>
   <title>Test</title>
</head>
<body>
<h2>Thumbnail Test</h2>
[img]bild.php[/img]
Hallo wie gehts so?
</body>
</html>

bild.php:
[php:1:d65939c92f]<?php
include("klassen.php");
$bild = "forum_normal.png";
$thumbnails = new Bilder($bild);
$thumbnails->thumbnailCreate(100,200);
?>
[/php:1:d65939c92f]

so irgendwie. ist jetzt in keinster weise getestet. :roll:
 
Ahhhhhhhhh

so geht das also...

;heart - dank

Endlich sind meine Probs gelöst :D


Edit:

*********Delete by Me, weil: selber gelöst :p*********
 
Werbung:
Status
Für weitere Antworten geschlossen.
Zurück
Oben