Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    cache di immagini dinamiche

    Come si puo fare la cache di immagini create attraverso le libreruie GD?
    Qualche suggerimento?

    ciao
    www.meteowebcam.it
    La migliore raccolta di webcam meteo Italiane

    www.creazionigrafiche.com
    Grafica e siti web d'autore

  2. #2
    qualcuno mi puo dare una mano

    $page_id = $image;
    $timeout = 60000;
    $path = "./chached/".$page_id;

    if(!file_exists("./chached /"))
    mkdir("./chached /");

    if(file_exists($path) and filemtime($path) + $timeout > time()) {
    $result = readfile($path);
    if($result)
    exit();
    }

    set_time_limit(0);
    ob_start();


    // all seems to be OK so start the processing
    // create the new image using the tnsize parameter
    $tnimage = ImageCreateTrueColor($tnsize, $tnsize);
    // allocate the background colour for the thumbnail
    $darkblue = ImageColorAllocate($tnimage, 0, 0, 127);
    // set the background as transparent
    ImageColorTransparent($tnimage,$darkblue);
    // get the parameters of the big image
    $sz = GetImageSize($image);
    // load our internal variables
    $x = $sz[0]; // big image width
    $y = $sz[1]; // big image height
    // find the larger dimension
    if ($x>$y) { // if it is the width then
    $dx = 0; // the left side of the new image
    $w = $tnsize; // the width of the new image
    $h = ($y / $x) * $tnsize; // the height of the new image
    $dy = ($tnsize - $h) / 2; // the top of the new image
    }else{ // if the height is larger then
    $dy = 0; // the top of the new image
    $h = $tnsize; // the height of the new image
    $w = ($x / $y) * $tnsize; // the width of the new image
    $dx = ($tnsize - $w) / 2; // the left edgeof the new image
    }

    // copy the resized version into the thumbnal image
    ImageCopyResized($tnimage, $bigimage, $dx, $dy, 0, 0, $w, $h, $x, $y);
    // generate the Gif image
    ImageJpeg($tnimage);

    $output = ob_get_flush();

    $fp = fopen($path, "w");
    fwrite($fp, $output, strlen($output));
    fclose($fp);

    // release the memory used by the thumbnail image
    //ImageDestroy($tnimage);
    // release the memory used by the original big image
    //ImageDestroy($bigimage);
    // all done!
    ?>
    www.meteowebcam.it
    La migliore raccolta di webcam meteo Italiane

    www.creazionigrafiche.com
    Grafica e siti web d'autore

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.