martinlittle.com:thinkThin

thinkThin|archives|comments|gallery|unwired|guestbook|wiki|contact|about

If technology doesn't seem like magic, it's probably obsolete

I'm finding less time to update my blog these days, but my flickr photostream is often updated.

Playing in my house right now...

At 13:05 GMT on Wednesday I was listening to:

More of what I've been listening to

Latest pictures from my phone

www.flickr.com
More pictures from my phone


Sunday April 27 2003 at 16:51 GMT

Valid CSS! On Saturday I had some fun playing around with my site. My CSS has never been too shiny, so I decided to take an hour and clean it up. As you can see, my site is now lovely and compliant. There are three warnings I get when I apply the strictest validation settings to my CSS file, but these are only for small workarounds for the Opera browser, so I'm happy with that.

For a while I've been meaning to get some auto-image-resizing code written for my gallery, so that I could just dump full-scale camera images into a directory and the resizing and decrease in quality (from original photo) would be taken care without me doing any more work. I got the code written with not too many problems, so it is auto-thumbnailing for the latest gallery. The problem I've found is that a) the quality is rubbish; b) the files are double the size compared to doing this in LView. Compare:

Lview original20% quality50% quality80% quality
1975bytes1483bytes2164bytes3323bytes

Here's my PHP code:

if ($galleryName == "latest") { $thumbnailLocation = $baseFileLocation . $galleryYear . "/" . $galleryName . "/thumbnail/" . $imageName; //echo($thumbnailLocation); if (!file_exists($thumbnailLocation)) { $largefileLocation = str_replace('thumbnail', 'large', $thumbnailLocation); $originalimagesize = getimagesize($largefileLocation); $originalimagewidth = $originalimagesize[0]; //echo($originalimagewidth); $originalimageheight = $originalimagesize[1]; //echo($originalimageheight); if (($originalimagewidth > $thumbnailWidth) || ($originalimageheight > $thumbnailHeight)) { $mltwidth = $thumbnailWidth / $originalimagewidth; //echo("mltw" . $mltwidth); $mltheight = $thumbnailHeight / $originalimageheight; //echo("mlth" . $mltheight); $mlt = $mltwidth < $mltheight ? $mltwidth:$mltheight; //echo("mlt" . $mlt); $newimagewidth = round($originalimagewidth * $mlt); //echo($newimagewidth); $newimageheight = round($originalimageheight * $mlt); //echo($newimageheight); $resizedimage = imagecreate($newimagewidth, $newimageheight); imagecopyresized($resizedimage, imagecreatefromjpeg($largefileLocation), 0, 0, 0, 0, $newimagewidth, $newimageheight, $originalimagewidth, $originalimageheight); imagejpeg($resizedimage, $thumbnailLocation); }

At the moment, I'm leaving the quality at 100%. If anyone has any bright ideas on how I can increase the quality to be at least as good as the LView original whilst keeping the size about the same as the LView original, I'd be most happy to hear them.


Comments

Name and email address are required; email address will NOT be displayed.
Name:
Email:
Web site (optional):
Comment:
Type the word thinkthin in the box, or else your comment will not be added. Type very carefully, 'cos if it's mistyped, you'll lose your comment:

Valid XHTML 1.0! Valid CSS! [Valid RSS] GeoURL

Powered by
thinkthin