Thumbnailer.php

d-signZ
Verfügbare Informationen zu "Thumbnailer.php"

  • Qualität des Beitrags: 0 Sterne
  • Beteiligte Poster: Kima - d-signz
  • Forum: d-signZ
  • aus dem Unterforum: HTML/PHP
  • Antworten: 2
  • Forum gestartet am: Mittwoch 16.05.2007
  • Sprache: deutsch
  • Link zum Originaltopic: Thumbnailer.php
  • Letzte Antwort: vor 16 Jahren, 11 Monaten, 4 Tagen, 21 Stunden,
  • Alle Beiträge und Antworten zu "Thumbnailer.php"

    Re: Thumbnailer.php

    Kima - 16.05.2007, 20:38

    Thumbnailer.php
    Hab mich mal hingesetzt und einen Thumbnailer (wie bei imageshack) geschrieben.

    Funktioniert mit allen mir geläufigen Browser (oder besser sollte ;)).
    Funktioniert aber nur mit den Formaten .jpg, .gif und .png
    Hier ist der Code

    Code: <?php
    $srcFile = 'vectorwally.png';
    list($width, $height, $type, $attr) = getimagesize($srcFile);

    switch($type)
    {
       case 1:       //GIF
          $src = imagecreatefromgif($srcFile);
          break;
       case 2:       //JPEG
          $src = imagecreatefromjpeg($srcFile);
          break;
       case 3:       //PNG
          $src = imagecreatefrompng($srcFile);
          break;
       default:
          return false;
          break;
    }

    $fileSize = ceil(filesize($srcFile) / 1024);
    $tmbWidth = 150;
    $tmbHeight = 130;
    $tmbImageHeight = 107;
    $borderSize = 3;

    if ($width > $height)
    {
       $newWidth = $tmbWidth - (2 * $borderSize);
       $newHeight = $height * ($newWidth/$width);
    }
    else
    {
       $newHeight = $tmbImageHeight;
       $newWidth = $width * ($newHeight/$height);
    }

    $tmbX = ceil(($tmbWidth - $newWidth) / 2);
    $tmbY = ceil((($tmbImageHeight - $newHeight) / 2) + $borderSize);

    $thumb = imagecreatetruecolor($tmbWidth, $tmbHeight) or die ("Cannot Create image!");

    $bg_color = imagecolorallocate($thumb, 37, 90, 112);
    imagefilledrectangle($thumb, 0, 0, $tmbWidth, $tmbHeight, $bg_color);

    $textColour = imagecolorallocate($thumb, 255, 255, 255);
    $string = "{$width}x{$height}  {$fileSize}kB";
    $stringLength = strlen($string);
    $fontSize = 9;
    $letterWidth = 7;
    $textX = ($tmbWidth - ($stringLength * $letterWidth)) / 2;
    $textY = 124;

    imagettftext($thumb, $fontSize, 0, $textX, $textY, $textColour, 'library/monospace.ttf', $string);
    imagecopyresampled($thumb, $src, $tmbX, $tmbY, 0, 0, $newWidth, $newHeight, $width, $height);

    header("Content-type: image/png");
    imagepng($thumb);
    ?>



    Re: Thumbnailer.php

    d-signz - 19.05.2007, 12:24


    sehr schön werd in mal testen und komment abgeben ;)



    Mit folgendem Code, können Sie den Beitrag ganz bequem auf ihrer Homepage verlinken



    Weitere Beiträge aus dem Forum d-signZ



    Ähnliche Beiträge wie "Thumbnailer.php"

    http://gensud.ge.funpic.de/forum/phpBB2/index.php MACHT WERB - Anonymous (Samstag 07.05.2005)
    Truppenübersicht - http://truppen.macaputo.de/index.php - pizza1 (Donnerstag 29.12.2005)
    http://www.motorschirm-verband.de/forum/index.php - Johannes (Dienstag 13.03.2007)
    http://idesitv.com/db/index.php - Preity (Sonntag 18.02.2007)
    Nina total verzweifelt... php Dummheit oder so - Korppi (Mittwoch 18.01.2006)
    Erklärung PHP - Rolf (Freitag 25.05.2007)
    PHP Zeitmessung - carsten (Montag 25.06.2007)
    SuDDenDeAtH kann kein php HAHA! - liquid (Dienstag 18.04.2006)
    http://www.base-surf.com/index.php - Annily2004 (Dienstag 06.03.2007)
    http://www.toplistenservice.de/generator.php?id=13595&su - endgegner (Mittwoch 21.06.2006)