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
| <?php
//ce document est une image au format GIF
header("Content-type: image/gif");
//temps + 4 heures - 10 minutes en timestamp
$timestamp = time() + 4 * 60 * 60 - 60 * 10;
//temps au format AAAA_MM_JJ_HH_mm
$time = date("Y_m_d_H_i", $timestamp);
//temps arrondi au dernier 10 minutes
$last_time = substr($time, 0, -1)."0";
//génération de l'URL
$url = "http://www.meteo.gc.ca/data/radar/temp_image/WMN/WMN_CAPPI_RAIN_".$last_time.".GIF";
//génération de l'image à partir de l'URL
$image = imagecreatefromgif($url);
//génération du document de l'image finale
$image_finale = imagecreatetruecolor(478, 478);
//suppression de la couleur de fond
$fond = imagecolorclosest($image, 153, 153, 102);
imagecolorset($image, $fond, 255, 255, 255);
//suppression de l'eau
$eau = imagecolorclosest($image, 52, 50, 100);
imagecolorset($image, $eau, 255, 255, 255);
//suppression de l'inutile
imagecopyresized($image_finale, $image, 0, 0, 1, 1, 478, 478, 478, 478);
//ajout du logo
$logo = imagecreatefromgif("logo.gif");
imagecopy($image_finale, $logo, 0, 0, 0, 0, 117, 17);
//on rend le fond transparent
$trans = imagecolorclosest($image_finale, 255, 255, 255);
imagecolortransparent($image_finale, $trans);
//on retourne l'image
imagegif($image_finale);
?> |
Partager