Citation :
//calcul des dimensions de la photo
$size = @getimagesize($_FILES['chemin']['tmp_name']);
$photo = $_FILES['chemin']['name'];
copy ($_FILES['chemin']['tmp_name'], 'E:\site internet\albert sports\grande\\'.$photo.'');
$source = imagecreatefromjpeg('grande\\'.$photo); // La photo est la source
if ($size[1] > $size[0]) // photo en portrait
{
$destination = imagecreatetruecolor($ratio, round(($ratio/$size[0])*$size[1]));
imagecopyresampled($destination, $source, 0, 0, 0, 0, $ratio, round($size[1]*($ratio/$size[0])), $size[0], $size[1]);
echo "<a class='avertissement'>Image bien ajouter</a>";
}else // photo en paysage
{ // Creation de la miniature
$destination = imagecreatetruecolor(round(($ratio/$size[1])*$size[0]), $ratio);// On crée la miniature vide
imagecopyresampled($destination, $source, 0, 0, 0, 0, round(($ratio/$size[1])*$size[0]), $ratio, $size[0], $size[1]);
echo "<a class='avertissement'>Image bien ajouter</a>";
}
// on copie la petite image ds le dossier correspondant
imagejpeg ($destination, 'E:\site internet\albert sports\mini\\'.$photo.'');
|