Creating thumbnails on the fly under FastCGI

Posted by robbiebow on 15 September, 2007 under perl | Be the First to Comment

A while ago I wrote about the problems I was having with trying to get Image::Magick to create thumbnails on the fly whilst running under FastCGI. Well, I was right then that the problem lay in the fact that FCGI ties STDOUT whilst Image::Magick also wants to access STDOUT to write to. I spent a couple more hours trying to figure out how to untie STDOUT, do the Image::Magick->Write to STDOUT then re-attach it to FCGI. No luck. The FCGI->Detach method didn’t do it. Under hood was too complex for me to understand.

I retreated and looked at GD again. Similar problems, as well as a messier interface. Then I had a gander around seach.cpan.org and picked up on Imager. Thanks to the handy rating stars on the search pages it looked promising. And really, it is a breath of fresh air: well documented, developer-friendly interface, myriad options and ways to play with images (including the scale() method which automatically scales in proportion). And, crucially, you can write() your images to a scalar variable, which means you can then print that scalar and FCGI will scoop it up and print it out like any other print statement.

Job done: I can now make thumbnail images on the fly and send them back to the browser under FastCGI by dropping Image::Magick for the new and very impressive Imager.

Read more of this article »

Some things never change

Posted by robbiebow on under politics | Be the First to Comment

Politicians will always tend towards large scale monolithic answers which are almost always the wrong answer and involve selling the family silver in one shape or another. Take the current answer to the current housing shortage in the South East, which is, build more house in the South East. Yet catch a train from London to Edinburgh and you’ll pass by towns like Doncaster where there are empty houses strewn about the place. We have the housing stock; just that we have an infrastructure geared towards draining all the working age young adults to the South East to spend their useful days working in the Hell that is London. We don’t have a housing shortage nationwide.

The smart answer would be to move the jobs for which the people are sucked into London to the Doncasters and Burys of this country. There are 200,000 civil servants in London (each generating  approximately 3 other jobs, making 800,000 jobs, representing 3 million people inc. the families.) Move entire ministries – including their mandarins and ministers – out of London to cheaper areas of the country with spare capacity. That frees up real estate in London and its satellites, regenerates depressed areas, reduces running costs (cheaper buildings, no more London weighting allowance) and makes national government national, not London-centric, and you preserve the green belt, the fens, Wolds, Downs and Chiltern hills from myriad new Cambournes and Peterboroughs.

Read more of this article »