skip to content

DerekAllard.com : CodeIgniter, ExpressionEngine, and the World of Web Design

Most Useless Code Igniter Helper Ever?

January 23rd, 2007

Have I written the most useless helper Code Igniter will ever see? I think so.

It takes an arbitrary image and arbitrary text and builds an image out of them.

Code Igniter logo becomes Code Igniter logo as text(full size)

Which really doesn't do it justice until you see it full size, or run the demo. Here's a zoom.
Code Igniter logo as text zoomed in

  • Completely impractical? CHECK!
  • Chew up server and browser resources? CHECK!
  • Fun to take images and overlay completely stupid slogans and sayings? BIG CHECK!

I should note that the helper handles colours just fine. Here's the rendered robot (2.7MB... be kind)

A red robotRed robot Rendered as text

I proudly present the most useless helper ever written! The (useless) helper is available for download, and I've appropriately named it "useless_fun_helper". Run it just like you'd run any other helper.

$this->load->helper('useless_fun');
$txt = 'Code Igniter is an Open Source Web Application Framework that makes writing kick-ass PHP programs simple as apple pie';
$img = 'http://yourserver/ci_logo.jpg';
echo image_to_text($img, $txt); // typically you'd pass that into a view... I know... no hate mail ok

So this is my formal entry into the most useless helper of all time. Any runner-ups?

This entry was made on January 23rd, 2007 @ 8:50 and filed into CodeIgniter, PHP.

Comments

Yannick wrote on January 23rd, 2007 @ 13:23

LOL you’re right it is the most useless helper of all time. :P But looks cool though. :)

Shadowhand wrote on January 23rd, 2007 @ 14:38

That could be the most interesting, but (as you said) completely useless, code ever. Well done, man!

kea13 wrote on January 24th, 2007 @ 1:27

sorry, but I beg to differ ... wouldn’t such an image make for a pretty neat captcha?

Well, methinks there goes the uselessness right down the drain :)

Shadowhand wrote on January 24th, 2007 @ 5:44

I just had another thought Derek. What happens when you wrap the whole thing in a div with the following style?

font-size: 0.8em;

letter-spacing: -0.3em;

line-height: 0.5em;

Answer: It gives a higher "DPI" image.

Derek wrote on January 24th, 2007 @ 5:54

Hey Shadowhand - good observations.

I’d actually done exactly that (check out the "demo" page).  There seems to be minimum font-size in Firefox that I wasn’t aware of (around 6 pixels or so) that prevent it from being as high a "resolution" image as in IE.

I played with hiding some of the text with overflow: hidden and a few other stunts… but then I decided that really my time was worth a bit more then that.

@kea13: actually, you’re right that this could be a pretty neat technique for captchas, but currently the processing power required to do them would make them make this seem not feasible.  Even rendering my static demo on a pretty fast computer takes a bit of time.  Even the static is 922K, about the size of a digital picture.  I know I could get the filesize down dramatically with some creative css’ing (using a single character element instead of span would shave LOTS of Ks down).

Aaron wrote on January 25th, 2007 @ 0:15

I disagree about it being useless.

If you have a database format or need to transfer data that is not compatible with binary storage (many databases will not allow you to store images directly, only the references to them), this process would allow you to convert the image to text and then render the text (or run it through a de-converter) Admittedly its uses are limited but they are there.

I know because I had a requirement to capture a signature (as a gif) from a pda and send it via GPRS (insufficuent bandwidth/technology to send as an image) and store it in an Access database where it could be rendererd on screen in a customer service module.  We used a gif2txt converter at one end and a txt2gif converter at the other.

Primathon wrote on January 31st, 2007 @ 6:59

So very useless, yet so very neat. +10 points for creativity :)

Ankur wrote on February 02nd, 2007 @ 7:28

hey that looks awesome! It may be useless but its awesome!

Derek wrote on April 10th, 2007 @ 16:22

For anyone subscribed to this, I had to point out Alexander “Iksander” Springmeye’s creative contribution to this mess.  He’s made a guest post to my blog entitled Not so useless! image_to_text() as a CAPTCHA.

Post a Comment

Sorry, comments are automatically closed after 45 days, or sooner if one entry gets targetted by spammers. Why not contact me directly?