Tuesday, September 16, 2008

My Favorite Firefox Extensions

Sorry for writing yet another post about Firefox extensions. I just had to :) Here are the ones I use everyday:

General

Flashgot – integrates firefox to your external download manager application

Flashblock – blocks flash objects on websites on load. Just click on a flash object to enable it (this also supports white listing for sites like youtube)

ClumsyFingers – this prevents firefox from adding .com or .net to the URL whenever you accidentally press shift+enter on the location bar.

Download Statusbar – displays downloads on the lower portion of the browser rather than a popup window

Hide Menubar – hides the menu bar to save precious screen space. Menu bar will still show whenever you press Alt.

Stylish – allows you to change the style of any site you are browsing


Web Services

Delicious – Post bookmarks to your delicious account!

Google Notebook – very useful tool for information gathering or researching. Just drag and drop any web page element and it will automatically be stored on your Google Notebook.

Stumble Upon – fun stuff :)


Web Development

Web Developer Toolbar – essential tool for every web developer

Firebug – another essential tool, especially for debugging javascript

ColorZilla – simple tool to pick a color from any website

Regular Expressions Tester – a tool to test your regular expressions (haha)

Monday, September 15, 2008

Asido: A PHP Thumbnailer/ Resizer Class

I was using class.upload for some time until a resize function (framing) I was using didn't work properly on my new server setup. So I looked for other PHP image processing classes I can find, but I realized that there is nothing that is actively developed. I also tried phpThumb but I had problems when I used it on some shared hosts.

Asido

I like Asido because of it's simple API. Unfortunately, it also has some problems and the latest release on its website was April 2007 (outdated). The most updated version which is pure PHP5 can be downloaded on the project's SVN repository (click the Download GNU tarball link).

Lets's fix it!

Jpeg Quality
The API on the website didn't show how to adjust the quality when saving files as JPEG. It defaults to 80% quality which is quite low for my taste. So here's how to adjust the quality:

define('ASIDO_GD_JPEG_QUALITY', 90)
require_once('asido/class.asido.php');


Resizing Quality
Another problem is the bad image quality when resizing using GD. There's a simple fix to this. Open class.driver.gd.php and replace imageCopyResized with imageCopyResampled inside the __resize function:

Protected Function __resize(asido_tmp $tmp, $width, $height) {

// create new target
//
$_ = imageCreateTrueColor($width, $height);
imageSaveAlpha($_, true);
imageAlphaBlending($_, false);

$r = imageCopyResampled(
$_, $tmp->target,
0,0,
0,0,
$width, $height,
$tmp->image_width, $tmp->image_height
);

// set new target
//
$this->__destroy_target($tmp);
$tmp->target = $_;

return $r;
}

That's it! now Asido works great! one function that I like about it is it's Frame function (which other classes don't have). What it does is create fixed size thumbnails (aspect ratio is maintained, and the empty spaces are filled with a background color).