Ankündigung

Einklappen
Keine Ankündigung bisher.

Suche dynamische Gallerie

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Suche dynamische Gallerie

    Hallo Gemeinde,

    ich suche ein einfaches Script, das *.jpg-Dateien (in einer bereits bestehenden Ordnerstruktur) uebersichtlich als dynamisch generierte Thumbnails auf einer Seite darstellt. Bei Klick auf ein Thumbnail sollte am besten einfach das Bild angezeigt werden, ohne in eine HTML-Seite eingebettet zu sein. Also einfach den Pfad zum Quellbild als Link, in der Art http://server.de/images/image.jpg

    Gut waere wenn alles schoen simpel gehalten ist; also moeglichst nur eine PHP-Datei und nicht viel Design drumrum. Letzteres ist sicher weniger wichtig, ich kann HTML und CSS auch abspecken und anpassen.

    Ich habe auch selbst viel gesucht und ausprobiert aber noch nichts (sub-)optimales gefunden.. vielleicht hat hier ja jemand einen guten Tipp.

    Vielen Dank,
    jlsksr

  • #2
    Hallo und Willkommen im Forum!

    Du suchst eigentlich nur eine Thumbnailfunktion also ein Script für eine Bildervorschau!

    Ich habe da eine zur Verfügung!

    Wenn interesse melde dich per PN da erkläre ich dir alles wenns Probleme gibt!

    mfg der litter
    Aus dem Dynamo Lande kommen wir. Trinken immer reichlich kühles Bier. Und dann sind wir alle voll, die Stimmung ist so toll. Aus dem Dynamo Lande kommen wir.
    [URL]http://www.lit-web.de[/URL]

    Kommentar


    • #3
      Gibts doch sicher wie Sand am Meer...
      [COLOR="#F5F5FF"]--[/COLOR]
      [COLOR="Gray"][SIZE="6"][FONT="Georgia"][B]^^ O.O[/B][/FONT] [/SIZE]
      „Emoticons machen einen Beitrag etwas freundlicher. Deine wirken zwar fachlich richtig sein, aber meist ziemlich uninteressant.
      [URL="http://www.php.de/javascript-ajax-und-mehr/107400-draggable-sorttable-setattribute.html#post788799"][B]Wenn man nur Text sieht, haben viele junge Entwickler keine interesse, diese stumpfen Texte zu lesen.“[/B][/URL][/COLOR]
      [COLOR="#F5F5FF"]
      --[/COLOR]

      Kommentar


      • #4
        Hey, wenn du das Skript etwas anpasst und die richtigen Parameter uebergibst, funktioniert es wunderbar - mit Cache. Der obere Teil ist Validierung von mir, der untere Teil leistet die Arbeit und sollte fuer dich relevant sein:
        PHP-Code:
        <?php
        require_once "../../includes/prepend.inc.php";

        $strClass           = (string)$_GET["class"];
        $intImage           = (int)$_GET["image_id"];
        $mixOption          = (string)@$_GET["option"];
        $strVirtualFilename = (string)@$_GET["virtual_filename"];
        $strExtension       = (string)@$_GET["extension"];

        $objImage null;
        if (
        $strClass == "auction") {
            if (empty(
        $intImage)) {
                
        $objImage AuctionImage::DumpDefault();
            } else {
                
        $objImage AuctionImage::Load($intImage);
            }
        } else if (
        $strClass == "user") {
            if (empty(
        $intImage)) {
                
        $objImage UserImage::DumpDefault();
            } else {
                
        $objImage UserImage::Load($intImage);
            }
        }

        if (!
        $objImage instanceof PhysicalFile) {
            die(
        "unknown image"); // TODO
        }
        if (!
        file_exists($objImage->GetServerPath())) {
            die(
        "file representation missing"); // TODO
        }

        if (
        $strVirtualFilename != basename($objImage->GetVirtualPath(), PATHINFO_FILENAME)) {
            
        //Debug::Stop($strVirtualFilename, $objImage->GetVirtualPath());
            // wrong virtual path, maybe renamed, let's publish that
            
        header("Location: " $objImage->GetVirtualPath($mixOption), true302);
            exit;
        }

        $image $objImage->GetServerPath();
        //Debug::stop($objImage->Source, $image);

        switch ($mixOption) {
            case 
        AuctionImage::Small:
                
        $maxWidth null;
                
        $maxHeight 75;
                break;
            case 
        AuctionImage::Medium:
                
        $maxWidth null;
                
        $maxHeight 250;
                break;
            case 
        AuctionImage::Large:
                
        $maxWidth 640;
                
        $maxHeight null;
                break;
            case 
        AuctionImage::Original:
                
        $maxWidth 2500;
                
        $maxHeight 2500;
                break;
            default:
                die(
        "unknown image option");
        }



        $memoryToAllocate   '100M';
        $defaultQuality     90;
        $currentDir         dirname(__FILE__);
        $cacheDir           __TMP__ "/";


        // Get the size and MIME type of the requested image
        $size   GetImageSize($image);
        $mime   $size['mime'];

        $width          $size[0];
        $height         $size[1];

        if (isset(
        $_GET['color']))
            
        $color      preg_replace('/[^0-9a-fA-F]/''', (string) $_GET['color']);
        else
            
        $color      FALSE;

        // If either a max width or max height are not specified, we default to something
        // large so the unspecified dimension isn't a constraint on our resized image.
        // If neither are specified but the color is, we aren't going to be resizing at
        // all, just coloring.
        if (!$maxWidth && $maxHeight)
        {
            
        $maxWidth   2500;
        }
        elseif (
        $maxWidth && !$maxHeight)
        {
            
        $maxHeight  2500;
        }
        elseif (
        $color && !$maxWidth && !$maxHeight)
        {
            
        $maxWidth   $width;
            
        $maxHeight  $height;
        }

        // If we don't have a max width or max height, OR the image is smaller than both
        // we do not want to resize it, so we simply output the original image and exit
        if ((!$maxWidth && !$maxHeight) || (!$color && $maxWidth >= $width && $maxHeight >= $height))
        {
            
        //echo $mime,
            
        header("Content-type: $mime");
            
        header('Content-Length: ' filesize($image));
            
        readfile($image);
            
        //die($image);
            
        exit();
        }

        // Ratio cropping
        $offsetX    0;
        $offsetY    0;

        if (isset(
        $_GET['cropratio']))
        {
            
        $cropRatio      explode(':', (string) $_GET['cropratio']);
            if (
        count($cropRatio) == 2)
            {
                
        $ratioComputed      $width $height;
                
        $cropRatioComputed  = (float) $cropRatio[0] / (float) $cropRatio[1];
                
                if (
        $ratioComputed $cropRatioComputed)
                { 
        // Image is too tall so we will crop the top and bottom
                    
        $origHeight $height;
                    
        $height     $width $cropRatioComputed;
                    
        $offsetY    = ($origHeight $height) / 2;
                }
                else if (
        $ratioComputed $cropRatioComputed)
                { 
        // Image is too wide so we will crop off the left and right sides
                    
        $origWidth  $width;
                    
        $width      $height $cropRatioComputed;
                    
        $offsetX    = ($origWidth $width) / 2;
                }
            }
        }

        // Setting up the ratios needed for resizing. We will compare these below to determine how to
        // resize the image (based on height or based on width)
        $xRatio     $maxWidth $width;
        $yRatio     $maxHeight $height;

        if (
        $xRatio $height $maxHeight)
        // Resize the image based on width
            
        $tnHeight   ceil($xRatio $height);
            
        $tnWidth    $maxWidth;
        }
        else 
        // Resize the image based on height
        {
            
        $tnWidth    ceil($yRatio $width);
            
        $tnHeight   $maxHeight;
        }

        // Determine the quality of the output image
        $quality    = (isset($_GET['quality'])) ? (int) $_GET['quality'] : $defaultQuality;

        // Before we actually do any crazy resizing of the image, we want to make sure that we
        // haven't already done this one at these dimensions. To the cache!
        // Note, cache must be world-readable

        // We store our cached image filenames as a hash of the dimensions and the original filename
        $resizedImageSource     $tnWidth 'x' $tnHeight 'x' $quality;
        if (
        $color)
            
        $resizedImageSource .= 'x' $color;
        if (isset(
        $_GET['cropratio']))
            
        $resizedImageSource .= 'x' . (string) $_GET['cropratio'];
        $resizedImageSource     .= '-' $image;

        $resizedImage   md5($resizedImageSource);
            
        $resized        $cacheDir $resizedImage ".cache";

        // Check the modified times of the cached file and the original file.
        // If the original file is older than the cached file, then we simply serve up the cached file
        if (!isset($_GET['nocache']) && file_exists($resized))
        {
            
        $imageModified  filemtime($image);
            
        $thumbModified  filemtime($resized);
            
            if(
        $imageModified $thumbModified) {
                
        // Check browser cache
                
        $gmdate_mod gmdate('D, d M Y H:i:s'$thumbModified) . " GMT";
                if (isset(
        $_SERVER['HTTP_IF_MODIFIED_SINCE']))
                {
                    
        $if_modified_since preg_replace('/;.*$/'''$_SERVER['HTTP_IF_MODIFIED_SINCE']);
                    if (
        $if_modified_since >= $gmdate_mod)
                    {
                        
        header("HTTP/1.1 304 Not Modified");
                        exit();
                    }
                }
                
                
        // Not cached in browser, so we send our cached version
                
        $size       GetImageSize($resized);
                
        header("Content-type: {$size['mime']}");
                
        header('Last-Modified: ' gmdate('D, d M Y H:i:s'$thumbModified) . ' GMT');
                
        header('Content-Length: ' filesize($resized));
                
        readfile($resized);
                exit();
            }
        }

        // We don't want to run out of memory
        ini_set('memory_limit'$memoryToAllocate);

        // Set up a blank canvas for our resized image (destination)
        $dst    imagecreatetruecolor($tnWidth$tnHeight);

        // Set up the appropriate image handling functions based on the original image's mime type
        switch ($size['mime'])
        {
            case 
        'image/gif':
                
        // We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
                // This is maybe not the ideal solution, but IE6 can suck it
                
        $creationFunction   'ImageCreateFromGif';
                
        $outputFunction     'ImagePng';
                
        $mime               'image/png'// We need to convert GIFs to PNGs
                
        $doSharpen          FALSE;
            break;
            
            case 
        'image/x-png':
            case 
        'image/png':
                
        $creationFunction   'ImageCreateFromPng';
                
        $outputFunction     'ImagePng';
                
        $doSharpen          FALSE;
                
        $quality            round(10 - ($quality 10)); // PNG needs a compression level of 0 (no compression) through 9
            
        break;
            
            default:
                
        $creationFunction   'ImageCreateFromJpeg';
                
        $outputFunction     'ImageJpeg';
                
        $doSharpen          TRUE;
            break;
        }

        // Read in the original image
        $src    $creationFunction($image);

        if (
        in_array($size['mime'], array('image/gif''image/png')))
        {
            if (!
        $color)
            {
                
        // If this is a GIF or a PNG, we need to set up transparency
                
        imagealphablending($dstfalse);
                
        imagesavealpha($dsttrue);
            }
            else
            {
                
        // Fill the background with the specified color for matting purposes
                
        if ($color[0] == '#')
                    
        $color substr($color1);
                
                
        $background FALSE;
                
                if (
        strlen($color) == 6)
                    
        $background imagecolorallocate($dsthexdec($color[0].$color[1]), hexdec($color[2].$color[3]), hexdec($color[4].$color[5]));
                else if (
        strlen($color) == 3)
                    
        $background imagecolorallocate($dsthexdec($color[0].$color[0]), hexdec($color[1].$color[1]), hexdec($color[2].$color[2]));
                if (
        $background)
                    
        imagefill($dst00$background);
            }
        }

        // Resample the original image into the resized canvas we set up earlier
        ImageCopyResampled($dst$src00$offsetX$offsetY$tnWidth$tnHeight$width$height);

        if (
        $doSharpen)
        {
            
        // Sharpen the image based on two things:
            //  (1) the difference between the original size and the final size
            //  (2) the final size
            
        $sharpness  findSharp($width$tnWidth);
            
            
        $sharpenMatrix  = array(
                array(-
        1, -2, -1),
                array(-
        2$sharpness 12, -2),
                array(-
        1, -2, -1)
            );
            
        $divisor        $sharpness;
            
        $offset         0;
            
        imageconvolution($dst$sharpenMatrix$divisor$offset);
        }

        // Write the resized image to the cache
        $outputFunction($dst$resized$quality);

        // Send the new image to the browser
        header("Content-type: $mime");
        header('Content-Length: ' filesize($resized));
        $outputFunction($dstnull$quality);

        // Clean up the memory
        ImageDestroy($src);
        ImageDestroy($dst);

        function 
        findSharp($orig$final) { // function from Ryan Rud (http://adryrun.com)
            
        $final  $final * (750.0 $orig);
            
        $a      52;
            
        $b      = -0.27810650887573124;
            
        $c      .00047337278106508946;
            
            
        $result $a $b $final $c $final $final;
            
            return 
        max(round($result), 0);
        }

        // old pond
        // a frog jumps
        // the sound of water

        // �Matsuo Basho


        // Smart Image Resizer 1.3.2
        // Resizes images, intelligently sharpens, crops based on width:height ratios, color fills
        // transparent GIFs and PNGs, and caches variations for optimal performance

        // Created by: Joe Lencioni (http://shiftingpixel.com)
        // Date: April 2, 2008
        // Based on: http://veryraw.com/history/2005/03/image-resizing-with-php/

        /////////////////////
        // LICENSE
        /////////////////////

        // I love to hear when my work is being used, so if you decide to use this, feel encouraged
        // to send me an email. Smart Image Resizer is released under a Creative Commons
        // Attribution-Share Alike 3.0 United States license
        // (http://creativecommons.org/licenses/by-sa/3.0/us/). All I ask is that you include a link
        // back to Shifting Pixel (either this page or shiftingpixel.com), but don�t worry about
        // including a big link on each page if you don�t want to�one will do just nicely. Feel
        // free to contact me to discuss any specifics (joe@shiftingpixel.com).

        /////////////////////
        // REQUIREMENTS
        /////////////////////

        // PHP and GD

        /////////////////////
        // PARAMETERS
        /////////////////////

        // Parameters need to be passed in through the URL's query string:
        // image        absolute path of local image starting with "/" (e.g. /images/toast.jpg)
        // width        maximum width of final image in pixels (e.g. 700)
        // height       maximum height of final image in pixels (e.g. 700)
        // color        (optional) background hex color for filling transparent PNGs (e.g. 900 or 16a942)
        // cropratio    (optional) ratio of width to height to crop final image (e.g. 1:1 or 3:2)
        // nocache      (optional) does not read image from the cache
        // quality      (optional, 0-100, default: 90) quality of output image

        /////////////////////
        // EXAMPLES
        /////////////////////

        // Resizing a JPEG:
        // <img src="/image.php/image-name.jpg?width=100&amp;height=100&amp;image=/path/to/image.jpg" alt="Don't forget your alt text" />

        // Resizing and cropping a JPEG into a square:
        // <img src="/image.php/image-name.jpg?width=100&amp;height=100&amp;cropratio=1:1&amp;image=/path/to/image.jpg" alt="Don't forget your alt text" />

        // Matting a PNG with #990000:
        // <img src="/image.php/image-name.png?color=900&amp;image=/path/to/image.png" alt="Don't forget your alt text" />

        /////////////////////
        // CODE STARTS HERE
        /////////////////////
        ?>
        "[URL="http://www.youtube.com/watch?v=yMAa_t9k2VA&feature=youtu.be&t=25s"]Mein Name ist Lohse, ich kaufe hier ein.[/URL]"

        Kommentar


        • #5
          Vielen Dank euch allen.
          Bei mir geht leider grad' Alles drunter und drueber, ich werde erst Mitte naechster Woche Zeit haben dein Script auszuprobieren, Chriz.

          Litterauspirna, wieso denn den Umweg ueber PM? Im Thread abgehandelt nuetzt das Wissen noch dem naechsten, der in unsere Richtung googelt. Und Geld wollte ich eh nicht bezahlen, falls es dir darum geht.

          (Trotzdem) Vielen Dank soweit.
          Bis die Tage.

          Kommentar

          Lädt...
          X