Stats on a image?

Discussion in 'Programming' started by Num Lock, Oct 31, 2007.

  1. #1
    Does anyone know how to put live stats on a image.

    For example I want to show how much a member of my site has made, so he can post the image/banner on forums, etc to attract members.
     
    Num Lock, Oct 31, 2007 IP
  2. liam1412

    liam1412 Active Member

    Messages:
    387
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You would need to provide a js oojeymawotsit that would call the image and dynamically create the image everytime it was called from the server. Or every time a new sale is made recreate the image so when a request is made from the other persons site it will effectively be live,.
     
    liam1412, Oct 31, 2007 IP
  3. Num Lock

    Num Lock Active Member

    Messages:
    1,802
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I have no idea what that means lol
     
    Num Lock, Oct 31, 2007 IP
  4. ndreamer

    ndreamer Guest

    Messages:
    339
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    lol, what you will need to do is learn php + GD, GD allows you to create images dynamically you may want to learn how to parse xml feeds as well.

    here is something i did a while ago which is very smiler to what you want to do.
    [​IMG]
     
    ndreamer, Oct 31, 2007 IP
  5. Num Lock

    Num Lock Active Member

    Messages:
    1,802
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Yea, that is exactly what i need, I was trying to find a code for one online but I came up empty handed so far.
     
    Num Lock, Oct 31, 2007 IP
  6. ndreamer

    ndreamer Guest

    Messages:
    339
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if you pm me i can give you a link to that code if you like, it's very messy but has everything you need to make the image.
     
    ndreamer, Oct 31, 2007 IP
  7. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #7
    [​IMG]
    Is one we made for a client with .Net as it is easy enough to do:

    
    Dim bitMapImage As Bitmap = New System.Drawing.Bitmap(Server.MapPath("~/images/bootprint.jpg"))
    Dim graphicImage As Graphics = Graphics.FromImage(bitMapImage)
    
    graphicImage.SmoothingMode = SmoothingMode.AntiAlias
    
    Dim Tlength As Integer = graphicImage.MeasureString(String.Format("{0:C2}", amount), New Font("Arial Black", 18, FontStyle.Regular)).Width
    Dim xpos As Integer = (bitMapImage.Width - Tlength) / 2
    graphicImage.TextRenderingHint = TextRenderingHint.AntiAlias
    graphicImage.DrawString(String.Format("{0:C2}", amount), New Font("Arial Black", 18, FontStyle.Regular), Brushes.White, xpos, 120)
    
    bitMapImage.Save(Response.OutputStream)
    
    graphicImage.Dispose()
    bitMapImage.Dispose()
    
    Code (.Net):
    Amount is a variable which is pulled from the db beforehand

    We also cache the page for 5 minutes to prevent too much server load
     
    AstarothSolutions, Oct 31, 2007 IP
  8. Num Lock

    Num Lock Active Member

    Messages:
    1,802
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Thanks, I will try it out.
     
    Num Lock, Nov 1, 2007 IP