par
Invité » 23 févr. 2008, 21:41
Effectivement je viens de découvrir ces fonctions et tout marche parfaitement.
J'ai fini la partie la plus délicate du site

Voici le code pour ceux que cela intéresse.
//récupère les infos en base.
header('Content-Type: '.$photo['photo_type']);
$source = imagecreatefromstring($photo['photo_blob']);
$width_src = imagesx($source);
$height_src = imagesy($source);
if ($width && ($width_src < $height_src)) {
$width = ($height / $height_src) * $width_src;
} else {
$height = ($width / $width_src) * $height_src;
}
$ext = explode("/", $photo['photo_type']);
$destination = imagecreatetruecolor ($width, $height) or die ("Erreur pour créer l'image");
// on créé un cadre autour de la miniature
$blanc = imagecolorallocate ($destination, 255, 255, 255);
$gris[0] = imagecolorallocate ($destination, 69, 69, 69);
$gris[1] = imagecolorallocate ($destination, 82, 82, 82);
$gris[2] = imagecolorallocate ($destination, 97, 97, 97);
$gris[3] = imagecolorallocate ($destination, 107, 107, 107);
$gris[4] = imagecolorallocate ($destination, 120, 120, 120);
$gris[5] = imagecolorallocate ($destination, 134, 134, 134);
$gris[6] = imagecolorallocate ($destination, 145, 145, 145);
for ($i=0; $i<7; $i++) {
imagefilledrectangle($destination, $i, $i, $width-$i, $height-$i, $gris[$i]);
}
// créé la miniature : attention fonction lourde
imagecopyresampled($destination, $source, 8, 8, 0, 0, $width-(2*8), $height-(2*8), $width_src, $height_src);
call_user_func('image'.$ext[1], $destination);
imagedestroy($source);
imagedestroy($destination);
Voici comment appeler la fonction :
Code : Tout sélectionner
<img src="image.php?id=<?php echo $photos[0]['photo_id']; ?>"/>
Merci de ton aide

Effectivement je viens de découvrir ces fonctions et tout marche parfaitement.
J'ai fini la partie la plus délicate du site :D
Voici le code pour ceux que cela intéresse.
[php]
//récupère les infos en base.
header('Content-Type: '.$photo['photo_type']);
$source = imagecreatefromstring($photo['photo_blob']);
$width_src = imagesx($source);
$height_src = imagesy($source);
if ($width && ($width_src < $height_src)) {
$width = ($height / $height_src) * $width_src;
} else {
$height = ($width / $width_src) * $height_src;
}
$ext = explode("/", $photo['photo_type']);
$destination = imagecreatetruecolor ($width, $height) or die ("Erreur pour créer l'image");
// on créé un cadre autour de la miniature
$blanc = imagecolorallocate ($destination, 255, 255, 255);
$gris[0] = imagecolorallocate ($destination, 69, 69, 69);
$gris[1] = imagecolorallocate ($destination, 82, 82, 82);
$gris[2] = imagecolorallocate ($destination, 97, 97, 97);
$gris[3] = imagecolorallocate ($destination, 107, 107, 107);
$gris[4] = imagecolorallocate ($destination, 120, 120, 120);
$gris[5] = imagecolorallocate ($destination, 134, 134, 134);
$gris[6] = imagecolorallocate ($destination, 145, 145, 145);
for ($i=0; $i<7; $i++) {
imagefilledrectangle($destination, $i, $i, $width-$i, $height-$i, $gris[$i]);
}
// créé la miniature : attention fonction lourde
imagecopyresampled($destination, $source, 8, 8, 0, 0, $width-(2*8), $height-(2*8), $width_src, $height_src);
call_user_func('image'.$ext[1], $destination);
imagedestroy($source);
imagedestroy($destination);
[/php]
Voici comment appeler la fonction :
[code]
<img src="image.php?id=<?php echo $photos[0]['photo_id']; ?>"/>
[/code]
Merci de ton aide :pouce: