Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
<img src="bildklein.php?bild='.$file.'">
<?
# <img src="bildklein.php?bild=4_jaegertunier/4.jpg">
# <a href="http://www.meinedomian.de/grossbild.jpg"><img src="bildklein.php?bild=http://www.meinedomian.de/grossbild.jpg"></a>
// Bilddaten feststellen
$size=getimagesize($_GET['bild']);
$breite=$size[0];
$hoehe=$size[1];
//hier die Breite festlegen
#$neueBreite=100;
#$neueHoehe=intval($hoehe*$neueBreite/$breite);
$neueHoehe=50;
$neueBreite=intval($breite*$neueHoehe/$hoehe);
if($size[2]==1) {
// GIF
$altesBild=ImageCreateFromGIF($_GET['bild']);
$neuesBild=ImageCreate($neueBreite,$neueHoehe);
ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
ImageGIF($neuesBild);
}
/*
elseif($size[2]==2) {
// JPG
$altesBild=ImageCreateFromJPEG($_GET['bild']);
$neuesBild=imagecreatetruecolor(100,100);
ImageCopyResized($neuesBild,$altesBild,-10,-20,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
ImageJPEG($neuesBild);
}
*/
elseif($size[2]==2) {
// JPG
$altesBild=ImageCreateFromJPEG($_GET['bild']);
$neuesBild=imagecreatetruecolor($neueBreite,$neueHoehe);
ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
ImageJPEG($neuesBild);
}
elseif($size[2]==3) {
// PNG
$altesBild=ImageCreateFromPNG($_GET['bild']);
$neuesBild=imagecreatetruecolor($neueBreite,$neueHoehe);
ImageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
ImagePNG($neuesBild);
}
?>
$maxthumbwidth = 50; # maximale Breite des Thumbails
$maxthumbheight = 50; # maximale Höhe des Thumbnails
$upload = 'Uploadordner';
$filename = $_FILES['foto']['name']; # aus <input type="file" name="foto">
$temp = $_FILES['foto']['tmp_name'];
move_uploaded_file($temp, "$upload/$filename"); # In den Uploadordner speichern
# Thumb erstellen
$imagesize = getimagesize("$upload/$filename");
$imagewidth = $imagesize[0];
$imageheight = $imagesize[1];
$imagetype = $imagesize[2];
$image = imagecreatefromjpeg("$upload/$filename");
# Ausmaße kopieren, wir gehen zuerst davon aus, dass das Bild schon Thumbnailgröße hat
$thumbwidth = $imagewidth;
$thumbheight = $imageheight;
# Breite skalieren falls nötig
if ($thumbwidth > $maxthumbwidth)
{
$factor = $maxthumbwidth / $thumbwidth;
$thumbwidth *= $factor;
$thumbheight *= $factor;
}
# Höhe skalieren, falls nötig
if ($thumbheight > $maxthumbheight)
{
$factor = $maxthumbheight / $thumbheight;
$thumbwidth *= $factor;
$thumbheight *= $factor;
}
# Thumbnail erstellen
$thumb = imagecreatetruecolor($thumbwidth, $thumbheight);
imagecopyresampled( # Thumbnail in Foto kopieren
$thumb,
$image,
0, 0, 0, 0, # Startposition des Ausschnittes
$thumbwidth, $thumbheight,
$imagewidth, $imageheight
);
$foto = "$filename";
# In Datei speichern
$thumbfile = "$upload/thumbs/$foto"; # Hier wird Thumb in Unterordner 'thumbs' gespeichert
imagepng($thumb, $thumbfile);
imagedestroy($thumb);
}
function resize($pfad,$extension)
{
$max_t_height = 50;
$max_t_width = 50;
if(!file_exists($pfad))
{
return false;
}
// Berechnungen
$size = getimagesize($pfad);
$breite = $size[0];
$hoehe = $size[1];
if($breite <= $hoehe)
{ // Bild ist im Hochformat
$neueHoehe = $max_t_height;
$neueBreite = intval($breite*$neueHoehe/$hoehe); // neue Breite berechnen
}
else
{ // Bild ist im Querformat
$neueBreite=$max_t_width;
$neueHoehe= intval($hoehe*$neueBreite/$breite); // neue Höhe berechnen
}
// Thumb erstellen
if($extension == 'jpg' or ($extension == 'jpeg'))
{
$altesBild = ImageCreateFromJPEG($pfad); // Altes Bild
}
elseif($extension == 'gif')
{
$altesBild = ImageCreateFromGIF($pfad); // Altes Bild
}
elseif($extension == 'png')
{
$altesBild = ImageCreateFromPNG($pfad); // Altes Bild
}
else return FALSE;
$neuesBild = @ImageCreateTruecolor($neueBreite,$neueHoehe); // Neues Bild wird erstellt
@imagecopyresampled($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe); // und das alte Bild wird verkleinert hineinkopiert
return $neuesBild; // das neue Bild wird zurückgegeben
}