writing dyn_image; a 'dynamic' image with php

on under docs
1 minute read

this is an old blog post from my previous blog

Who doesn't love a cool forum signature? How about one that changes everytime you refresh the page?

The first time I came into contact with dynamic images was when I saw this text on the popular mobile forum XDA-Developers; and it didn't take me long to trace it back to this guy here; AceInfinity. Inevitably, it found a way into my signature; and stayed there for a very long time.

Days rolled by; and I eventually almost forgot all about it; but there was a constant little voice at the back of my head reminding how awesome it was and the only thing that I remembered was that it was written in PHP.

I had no idea about PHP, but after 'quickly' making a project for an exhibition; I had a little idea about how PHP works.

So, quickly decided to come back and write one such piece of code myself. Quickly found my way to the imagecreate functions, and as a result, dyn_image!

You can find a live example here.

I wanted it to be truly 'useful' so, I added support for parameters, and support for reading text from external sources (currently, pastebin).

parameters:

  • ?id= pastebin id
  • ?text= fallback text
  • ?size= font size (1 - 5)
  • ?align= left|center|right
  • ?type= jpeg|gif|png|webp(experimental)
  • ?color= html color hex in argb
  • ?bg_color= html color hex in argb (or) transparent

    raw text delimiters:

  • \r\n: end of string1

  • \n: new line

  • \a: author

you can find an example of text here: http://pastebin.com/FeLudYh4

The above text is what I'm using over at XDA-Developers in my forum signature; with the following options:

  • ?id=FeLudYh4
  • ?type=png
  • ?size=2
  • ?align=left
  • ?color=0064ff
  • ?bg_color=transparent

What's more? Since I support open-source (a lot, usually); you can even find its source (here), and hack it up the way you want it to work!

That's me signing off; after trying to write documentation for the stupid things I sometimes write.

comments powered by Disqus