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
|
// Création des vignettes qui n'existent pas encore
$res_img_reduce = mysql_db_query($database,"select * from realisations_images where url_image_reduce=''");
$nb_img_reduce = mysql_num_rows($res_img_reduce);
$lig_img_reduce=1;
while($nb_img_reduce>=$lig_img_reduce){
$row_img_reduce = mysql_fetch_array($res_img_reduce);
$nom_image = basename($row_img_reduce['url_image']);
if(!file_exists($site."modules/Realisations/reduce/".$row_img_reduce['id_rea'])){
mkdir($site."modules/Realisations/reduce/".$row_img_reduce['id_rea']);
}
if(!file_exists("reduce/".$row_img_reduce['id_rea']."/".$nom_image)){
list($width, $height) = getimagesize($site.$row_img_reduce['url_image']);
$width_reduce = "150";
$height_reduce = ($width_reduce*$height)/$width;
$image_reduce = ImageCreate($width_reduce,$height_reduce);
$image = imagecreatefromjpeg($site.$row_img_reduce['url_image']);
ImageCopyResized($image_reduce,$image,0,0,0,0,$width_reduce,$height_reduce,$width,$height);
ImageJPEG($image_reduce,$site."modules/Realisations/reduce/".$row_img_reduce['id_rea']."/".$nom_image,100);
mysql_db_query($database,"update realisations_images set url_image_reduce='reduce/".$row_img_reduce['id_rea']."/".$nom_image."' where id='".$row_img_reduce['id']."' limit 1");
imagedestroy($image_reduce);
imagedestroy($image);
}
$lig_img_reduce++;
}
mysql_free_result($res_img_reduce);
// Fin de création des vignettes |
Partager