Improving image compression for Windows Live Writer
I did a bit of PHP coding this weekend (cue screams by programmers and a development managers everywhere). I liked Windows Live Writer the first time I ran it through it’s paces and now I like it even more. There is one serious caveat. The images that WLW creates and uploads are a bit “rich”. What I mean by that is they are bigger than they really need to be.
When I use GIMP and even Postie, I use a JPEG quality setting of 75. This seems to make reasonable small thumbnails for my blogs and even does a good job when the image is 575 px. On average, the 240px thumbnails are between 10kb and 20kb while the larger images are 50kb to 70kb. These sizes make it possible for readers using telephone modems and dial-up service to still have a chance to read the blog without falling asleep waiting for the page to load. I would like the pages to be even smaller but I use images in nearly every post so a typical page size is between 400kb and 500kb.
What I liked about WLW was that it took my basic images and create both a nice thumbnail with drop shadow effect and created all the necessary linking to the full size image. Postie did this too. The difference was I had to add the drop shadow to the big image and exaggerate it so that the thumbnail would have it when Postie scaled it down. Also, Postie make all thumbnails the same size and there was now way to control it on a post-by-post basis.
So, to get the control that I wanted I switched back to WLW but then I needed to find a fix for the larger that desirable image results. This is where that PHP comes in. I have created a crude but effective Wordpress plug-in that detects JPEG files in uploaded posts and re-compresses them automatically. I even gave it a crude name “jpeg-quality75″.
You can download jpeg-quality75 here if you are interested. The install is very simple – unzip then upload jpeg-quality75.php to your Wordpress plug-ins directory and activate it. It has not admin or settings.
The plug-in works by hooking the wp_handle_upload function in Wordpress. This function is called for every file uploaded, the plug-in checks if the file type is a JPEG image and if so, locates the image, opens and re-compresses it using a quality setting of 75, and then stores the result back in the original location, overwriting the original. It leaves PNG and GIF files alone.
I’ll be checking it’s results for a few days but it seems to be doing a good job without corrupting my photos and graphics.

I finally got around to upgrading this blog to the latest WordPress. the straw the broke the camel’s back – so to speak – was that Windows Live Writer now supports more XMLRPC interfaces included creating categories (in addition to just selecting from existing ones). There are also more complete interactions thru the XMLRPC interface.

