Buon Giorno spero di non sbagliare sezione
avrei bisogno di un'aiuto su php...ho prelevato in rete uno script di upload immagini,
che carica l'immagine e crea direttamente la thumbnail in 2 cartelle separate mantenendo il rapporto altezza/larghezza.
le immagini create mantengono un'altezza fissa (thumbnail 100px e immagine grande 400px) e varia la larghezza in base al rapporto,
io avrei bisogno solo per la thumbnail di mantenere oltre all'altezza anche la larghezza minima a 100px,
solo che non riesco a capire come modificare...qualcuno e' cosi' gentile da aiutarmi?
config.php
[PHP]
define('TMP_DIR', './tmp');
define('IMAGE_DIR', './img');
define('THUMB_DIR', './imgt');
define('IMAGE_QUALITY', 80);
define('THUMB_QUALITY', 70);
define('IMAGE_HEIGHT', 400);
define('THUMB_HEIGHT', 100);
[/PHP]
upload.php
[PHP]
if(!isset($_POST['submit_upload'])){
header("Location: form.php");
}else{
include_once 'config.php';
//faccio l'upload dell'img
include_once './include/upload.class.php';
if(!isset($_FILES)) $_FILES = $HTTP_POST_FILES;
if(!isset($_SERVER)) $_FILES = $HTTP_POST_VARS;
$up = new FileUpload(TMP_DIR); 
$up->RenameFile($_POST['new_name']); 
$up->Upload($_FILES['file']); 
//adesso ridimensiono l'img a 400 x 400 
include_once './include/image.class.php'; 
$img = new Image(TMP_DIR . '/' . $up->filename); 
//creo l'immagine sorgente 
$result = $img->CreateSourceImage(); 
//se il tipo di immagine è supportato 
//salvo 2 file: 
//uno con l'img grande e uno con l'img piccola 
//nelle rispettive directory 
if($result){ 
    //salvo l'immagine con altezza 400 lasciandola proporzionata 
    $img->SaveProportionateImage(IMAGE_DIR . '/' . $up->filename, IMAGE_QUALITY, IMAGE_HEIGHT); 
    //salvo l'immagine con altezza 75 lasciandola proporzionata 
    $img->SaveProportionateImage(THUMB_DIR . '/' . $up->filename, THUMB_QUALITY, THUMB_HEIGHT); 
    //libero la memoria cancellando l'immagine sorgente 
    $img->Free(); 
} 
//se il tipo di img non è supportata 
//o se il file uploadato nn è un immagine 
else 
    echo 'Immagine non valida<br/>'; 
//In ogni caso cancello il file uploadato nella cartella ./tmp 
$up->DeleteFile(); 
header("location: /Private/admin.php?p=lettura_gallery"); 
}[/PHP]
image.class.php
[PHP]
class Image{
var $src_filename;
var $src_witdh;
var $src_height;
var $src_type;
var $src_attr;
var $src_image;
function Image($filename){ 
    $this->src_filename = $filename; 
    $this->GetImageInfo(); 
} 
function GetImageInfo(){ 
    list($this->src_width,$this->src_height, $this->src_type, $this->src_attr) = getimagesize($this->src_filename); 
} 
function CreateSourceImage(){ 
    switch($this->src_type){ 
        case 1: 
            $this->src_image =imagecreatefromgif($this->src_filename); 
               break; 
        case 2: 
            $this->src_image =imagecreatefromjpeg($this->src_filename); 
        break; 
        case 3: 
             $this->src_image =imagecreatefrompng($this->src_filename); 
        break; 
        default:    return false; 
    } 
    return true; 
} 
function SaveProportionateImage($filename, $quality, $height){ 
    $dest_height = $height; 
    $ratio = $this->src_height / $dest_height; 
    $dest_image = imagecreatetruecolor( $this->src_width / $ratio,$dest_height); 
    imagecopyresampled($dest_image, $this->src_image, 0, 0, 0, 0, 
        $this->src_width / $ratio, 
        $this->src_height / $ratio, 
        $this->src_width, 
        $this->src_height); 
    imagejpeg($dest_image, $filename, $quality); 
    imagedestroy($dest_image); 
} 
function Free(){ 
    imagedestroy($this->src_image); 
} 
} [/PHP]
upload.class.php
[PHP]
class FileUpload{
var $up_dir;        //la directory temporanea in cui verrà uploadata l'img
var $filename;    //il nome del file
var $new_filename;    //il nuovo nome del file se vogliamo rinominarlo
function FileUpload($up_dir){ 
    $this->up_dir = $up_dir; 
} 
   
function RenameFile($new_filename){ 
    $this->new_filename = $new_filename; 
} 
function Upload($files){ 
    if(!file_exists($this->up_dir)) 
        die('La directory non esiste!'); 
    $this->filename = ($this->new_filename) ? $this->new_filename :$files['name']; 
    if(trim($files["name"]) == "") 
        die("Non hai indicato il file da uploadare!"); 
    if(is_uploaded_file($files["tmp_name"])){ 
        move_uploaded_file($files["tmp_name"],$this->up_dir."/".$this->filename) 
        or die("Impossibile spostare il file;controlla l'esistenza o i permessi della directory!"); 
    }else 
        die ("Problemi nell'upload del file ".$files["name"]); 
} 
        
function DeleteFile(){ 
    unlink($this->up_dir . '/' . $this->filename); 
} 
}[/PHP]
 ho letto molti post su questo forum, con risposte esaurienti da persone molto disponibili, cosa che non ho mai trovato in nessun forum, il che mi ha portato ad iscrivermi per porvi una domanda, sicuramente semplice per voi, non tanto per me agli inizi di php.