How to: add text to an image and save it as a file

Discussion in 'PHP' started by Fracisc, Oct 23, 2008.

  1. #1
    I need to add a few variables to an image and save the file on my web server. Those variables change in a few days so I also need a check if it is older then x days.
    How can I code that?
     
    Fracisc, Oct 23, 2008 IP
  2. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    ToddMicheau, Oct 23, 2008 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    No worries, I can add text to image, I don`t know how to save the image to my server and update in every 7 day.
     
    Fracisc, Oct 23, 2008 IP
  4. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Well updating every 7 days would be a mySql table and a cron job (checks the timestamp against current date and runs a function against the filename if it's so much apart). And saving it is no different than displaying it, except you take the data returned from the display function and write it to a file. . .

    Something like:
    
    $thumb = imagecreatetruecolor(100, 100);
    Imagejpeg($pic,"pic.jpg");
    ImageDestroy($pic);
    
    PHP:
    I do know that you need the correct permissions to save the file of course. . .
     
    ToddMicheau, Oct 23, 2008 IP
  5. salahsoftware

    salahsoftware Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    cronjob is a good option to do a task automatically. It will just call the script after a particular time interval.
     
    salahsoftware, Oct 24, 2008 IP