Uploading images with a firefox extension

May 6, 2009 at 10:34 am | In FireFox Extension, Website Development | Leave a Comment
Tags: , , , , , , , , ,

I’ve blogged before about some of the technology behind the free DirtMind image gallery so here’s some more…

For a long time I’ve wanted to make uploading and using images on forums simpler. FireFox gives us the capabilities to do this since when writing a firefox extension you’ve got access to a bit more functionality than you normally do from javascript as it’s trusted code.

The mission, upload an image by right clicking on it, generating all necessary BBCode.

The solution:

1) Write a nice XUL user interface for adding right click options to the firefox browser, selecting a local picture, establishing selection of a remote picture and providing nice upload feedback

2) Using the firefox extension encode the local image, or download a remote image and encode it (without saving a local file – that would be cheating)

3) Upload to the image host, decode the image data back into a picture.

After that it’s easy  because we’re just into the normal serverside image processing stuff that the image host does.

Here’s some screenshots of it in action:

Selecting an image to upload

Selecting an image to upload

The image uploaded

The image uploaded

Because of the other stuff I’ve blogged about before in terms of image captioning and deep site integration with phpBB you can now upload an image, caption it and post it extremely easily. Check out this HQ video of the whole process!

Or watch in in lower quality on youtubte:

Make your own lolcats, rofls and captions online

May 1, 2009 at 1:27 pm | In Blog, Website Development | Leave a Comment
Tags: , , , , , , , , , , , ,

I decided I wanted to allow DirtMind site members to be able to add captions to images easily so I set about thinking how to add an Image Captioner to the free DirtMind image hosting service. I intially talked to the developer of a well known online image captioner about getting his code to work as part of my site. Unfortunately though the backend technologies of his site and DirtMind didn’t mesh so I set about writing my own.

In the end this has had a lot of advantages as the Image captioner is far more specific to my design :) Server-side it’s pretty simple as I already had some image processing going on to watermark images with my site logo. Rather than make a stand alone image captioner I decided to integrate the functionality throughout the image gallery – that means all uploaded images are captionable. If you’re the owner of an image you can overwrite it with a captioned version, otherwise you can just save it as a new image (of course owners can do this too).

Of course some people will want a stand alone captioner, or at least a landing page so I created one for these people at www.dirtmind.com/captioner.php but this is really just a single file upload box that goes to the normal gallery pages :)

Play with it

As with everything at DirtMind it’s free and has no ads, if you want to try it out just look at any image on DirtMind! Here’s an example to play with (just click the pic).

You need to have a registered DM account to save your pic, or upload new ones, but you can play about with the captions without registering!

Technically the most challenging thing about doing this was the client side javascript. It seems that if you write something that works in FireFox then it pretty much works in Safari and Chrome. IE however has it’s own plans, and needs entirely different code. I spent a lot of time getting it to work in each platform. If you use another browser I’d appreciate you giving it a test run!

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.