index       article       [code]       qcm       citation       glossary public.pub.graz.network
  droit       JS       meteo       nivologie       NTIC       orientation       SUBCATEGORY        


  resize.exe.php

Code pour sauvegarder au format reduit toutes les images du répertoire courant.

<?php
set_time_limit
(320);
$cpt=1;
// Nouvelles tailles
$new_width 80;
$new_height 60;

$rep opendir('.');
while (
$file readdir($rep)){
    if (
$file !='..' && $file !='.' && $file !='' ){
        if (!
is_dir($file)){
            
// Le fichier destination
            
$fileDestination=$cpt.'.jpg';
            
            
// Le fichier source
            
$fileSource $file;
            
            
// Calcul des nouvelles dimensions
            
list($width$height) = getimagesize($fileSource);

            
// Redimensionnement
            
$image_p imagecreatetruecolor($new_width$new_height);
            
$image imagecreatefromjpeg($fileSource);
            
imagecopyresampled($image_p$image0000$new_width$new_height$width$height);
            
            
// Sauvegarde
            
imagejpeg($image_p$fileDestination100);
            
sleep(0.1);
            
$cpt++;
        }
    }
}
closedir($rep);
?>
1