1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| <?php include("header.php"); ?>
<?php
/********************************************fonction miniature ***********************************************/
# /*utilisation de la fonction :
# $path=chemin d'accès au dossier contenant la photo
# $fichierSource=nom de la photo
# $grand=taille du plus grand coté (hauteur pour les portraits, largeur pour les paysages)
# $destination=dossier de destination de la photo, par rapport à l'emplacement de la fonction */
function thumb($path,$fichierSource,$grand,$destination){
$ombre=$grand / 20;
//teste le format de l'image et crée l'image concerné
$image_size=@getimagesize($path.$fichierSource );
switch ( $image_size[2] ) {
case 1 :
$source = ImageCreateFromGif($path.$fichierSource);
$mime_photo='image/gif';
break;
case 2 :
$source = ImageCreateFromJPEG($path.$fichierSource);
$mime_photo='image/jpeg';
break;
case 3 :
$source = ImageCreateFromPNG($path.$fichierSource);
$mime_photo='image/png';
break;
default:
echo '<br />Erreur de format image <strong>'.$fichierSource.'</strong>. Seuls les formats jpeg, gif et png sont supportés';
return false;
}
$largeurSource = imagesx($source);
$hauteurSource = imagesy($source);
//calcul le rapport entre largeur et longueur...
$rapport_dim= $largeurSource / $hauteurSource;
//test si image en portrait ou en paysage
if ( $largeurSource >= $hauteurSource ) {
$largeurDestination = $grand;
$hauteurDestination = $largeurDestination / $rapport_dim;
}
else {
$hauteurDestination = $grand;
$largeurDestination = $hauteurDestination * $rapport_dim;
}
//crée l'image ( taille de l'imange source + taille de l'ombre)
$im = ImageCreateTrueColor ($largeurDestination + $ombre, $hauteurDestination + $ombre)
or die ('<br />Erreur lors de la création image <strong>'.$fichierSource.'</strong>');
//rempli le fond de blanc
$blanc=ImageColorAllocate ($im, 255, 255, 255);
ImageFill($im, 0, 0, $blanc);
ImageColorTransparent ($im, $blanc);
//crée l'ombre
$col = ImageColorAllocate ($im, 130 ,130 ,130 );
ImageFilledRectangle ($im, $ombre, $ombre, $largeurDestination + $ombre, $hauteurDestination + $ombre, $col);
//ajoute par dessus l'image source miniaturisée
ImageCopyResampled($im, $source, 0, 0, 0, 0, $largeurDestination, $hauteurDestination, $largeurSource, $hauteurSource);
$noir=ImageColorAllocate ($im, 0, 0, 0);
ImageRectangle($im,0,0, $largeurDestination, $hauteurDestination, $noir);
//crée la miniature
switch ( $mime_photo) {
case 'image/jpeg' :
ImageJpeg ($im, $destination.'/'.$fichierSource);
break;
case 'image/gif' :
ImageGif ($im, $destination.'/'.$fichierSource);
break;
case 'image/png' :
ImagePng ($im, $destination.'/'.$fichierSource);
break;
}
return true;
}
# /*utilisation de la fonction :
# $path=chemin d'accès au dossier contenant la photo
# $fichierSource=nom de la photo
# $grand=taille du plus grand coté (hauteur pour les portraits, largeur pour les paysages)
# $destination=dossier de destination de la photo, par rapport à l'emplacement de la fonction */
/************************************fin de la fontion******************************************************************/
$select=mysql_query("SELECT * FROM ".PREFIXE."galerie WHERE id_gal='$id_gal'") or die (mysql_error());
while($row=mysql_fetch_array($select))
{
$idg = htmlentities($row['idg']);
$id_gal =htmlentities($row['id_gal']);
$im = $row['gal'];
//contrôle de l'image vide dans le champ
if(!empty($im)){
thumb("imagess","$im", "200","imagess/mini");
echo'<div align="center"><a class="thumbnail" href="#thumb">
<img src="images/mini/'.$im.'" width="auto" height="auto" border="0" />
<span><img src="images/'.$im.'" /></span></a><br />';
if($id_gal == $pseudom){
echo'<td><div align="right"><a href="supp_image.php?idg='.$idg.'">Supprimer</a></div></td>';
}
}
}
?>
<?php include("footer.php"); ?> |