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?
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?