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

    Ridimensionamento immagini

    Come da oggetto,
    scusate la domanda un pò bislacca ma quelli che ho trovato non hanno funzionato bene, sicuramente per mia incapacità; comunque esiste uno script puro php per ridimensionare e quindi alleggerire le immagini per i formati più comuni... jpg o gif che sia collaudato e stabile??

    Grazie

  2. #2

  3. #3
    I hope there is a way back with my talisman
    so I look into myself to the days when I was just a child
    come follow me to wonderland and see the tale that never ends
    don't fear the lion nor the witch I can't come back
    I'm lost but still I know there is another world

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    346
    per le immagini in jpg e gif prova ad utilizzare questo script che le ridimensiona e le salva in due cartelle distinte in base ai valori da te scelti
    (puoi creare + immagini con dimensioni diverse in cartele distinte)

    tua pagina dove passi le variabili per memorizzare l'immagine:
    Codice PHP:
                    //-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
                   //---------> creo immagine ridotta x icona <---//
                   //-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
    $newname=$NOME_TUA_IMMAGINE   //rinomina qua l'id immagine
        
    $cur_dir="../".$img_big//dove hai l'immagine salvata con dimensioni reali
        
    $cur_file=$newname;  
        
    $w=110;  //larghezza
        
    $h=40;    //lunghezza
        
    $filepiccolo="../".$_small// directory immagini con dimensioni modificate
    // ."/".$newname;   

           
    resize($cur_dir$cur_file$w,$h$filepiccolo); 
    funzione pper ridimensionare
    Codice PHP:
    //==============================================================================
    //===============   FUNZIONE PER RIDIMENSIONARE   ==============================
    //==============================================================================


    function resize($cur_dir$cur_file$w,$h$output_dir)
    {

      
    $src=$cur_dir."/".$cur_file;
      
    $size getimagesize($src);

      if( 
    $size[2] == ){$im = @imagecreatefromjpeg("$src");}
      elseif( 
    $size[2] == ){$im = @imagecreatefromgif("$src");}
      elseif( 
    $size[2] == ){$im = @imagecreatefrompng("$src");}

      
    $newwidth $size[0];
      
    $newheight $size[1];

        if( 
    $newwidth $w ){
        
    $newheight = ($w $newwidth) * $newheight;
        
    $newwidth $w;
      }
      if( 
    $newheight $h ){
        
    $newwidth = ($h $newheight) * $newwidth;
        
    $newheight $h;
      }

      if( (
    GDVersion() == 2) AND ($size[2] != 1) ){
        
    $new imagecreatetruecolor($newwidth$newheight);
        
    imagecopyresampled($new$im0000$newwidth$newheight$size[0], $size[1]);
      }
      else{
        
    $new imagecreate($newwidth$newheight);
        
    imagecopyresized($new$im0000$newwidth$newheight$size[0], $size[1]);
      }

           
    $filename=$output_dir."/".$cur_file;
           @
    imagejpeg($new$filename);
       }


    function 
    GDVersion(){
      if( !
    in_array('gd'get_loaded_extensions()) ) return 0;
      elseif( 
    isGD2supported() ) return 2;
      else return 
    1;
    }


    function 
    isGD2supported(){
      global 
    $GD2;
      if( isset(
    $GD2) AND $GD2 ) return $GD2;
      else{
        
    $php_ver_arr explode('.'phpversion());
        
    $php_ver intval($php_ver_arr[0])*100+intval($php_ver_arr[1]);

        if( 
    $php_ver 402 ){ // PHP <= 4.1.x
          
    $GD2 in_array('imagegd2',get_extension_funcs("gd"));
        }
        elseif( 
    $php_ver 403 ){ // PHP = 4.2.x
          
    $im = @imagecreatetruecolor(1010);
          if( 
    $im ){
            
    $GD2 1;
            @
    imagedestroy($im);
          }
          else 
    $GD2 0;
        }
        else{ 
    // PHP = 4.3.x
          
    $GD2 function_exists('imagecreatetruecolor');
        }
      }

      return 
    $GD2;


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.