[PHP] GD - bestand wegschrijven

Pagina: 1
Acties:

Onderwerpen


  • njitter
  • Registratie: Oktober 2000
  • Niet online
Ik gebruik het volgende PHP script (niet zelf geschreven) om een dynamische signature image aan te maken

PHP:
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
<?
$month = 4; // Month of the countdown
$day = 3; // Day of the countdown
$year = 2005; // Year of the countdown

// mktime is the marked time, and time() is the current time.
$target = mktime(0,0,0,$month,$day,$year);
$diff = $target - time();

$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;

header ("Content-type: image/png");
$imgname = "cal2005.gif";
$im = @imagecreatefromgif ($imgname);

//Here are some common color codes in case you want to change the colors.
//$white = imagecolorallocate ($im, 255, 255, 255);
//$blue = imagecolorallocate ($im, 0, 0, 255);
//$black = imagecolorallocate ($im,0,0,0);
//$gray = imagecolorallocate ($im,153,153,153);
//$red = imagecolorallocate ($im,255,0,0);
//$orange = imagecolorallocate ($im, 255, 127, 36);

$background_color = imagecolorallocate ($im, 0, 0, 0);
$orange = imagecolorallocate ($im, 255, 127, 36);
$yellow = imagecolorallocate ($im, 247, 246, 201);
imagestring ($im, 3, 75, 35,  "[ nog $days dag(en) ] ", $orange);
imagegif ($im);
imagedestroy ($im);
?>


Ik wil de uitvoer nu naar een ander bestand wegschrijven zodat ik dit script 1x per dag kan schedulen. Het hoeft dan niet steeds uitgevoerd te worden (ik tel toch alleen maar de dagen).

Wie weet hoe dit met behulp van GD werkt?

  • Osiris
  • Registratie: Januari 2000
  • Niet online
Kijk hier eens.. En dan kom je er wel uit..

Handige site hoor, php.net...

  • Wolfboy
  • Registratie: Januari 2001
  • Niet online

Wolfboy

ubi dubium ibi libertas

Alle uitleg die je nodig hebt: http://php.net/imagegif

Blog [Stackoverflow] [LinkedIn]


  • Electronical
  • Registratie: Juli 2004
  • Laatst online: 18-11-2020
Je kunt met de imagefig() functie de filename meesturen:

bool imagegif ( resource image [, string filename])

edit:
En zie hierboven, net te laat

[ Voor 18% gewijzigd door Electronical op 17-02-2005 22:50 . Reden: Te laat... ]

I do not fear computers, I fear the lack of them - Isaac Asimov
"With enough eyeballs, all bugs are shallow" - Eric Raymond