Sunday 17 January 2010

Cutting out Pogs in Photoshop

This morning Clare stayed at home to look after G-Dad, L went to church with McRad, and me and Mauser went to the Catholic Church, as it was a Churches together service or sumat.

We got there about 15 minutes early as I didn't realise it was much closer than 'normal' church, but there were hardly any seats left. Quite a few people who arrived later than us had to stand up, so lucky we were so early.

There were about 400-500 people there, and the priest said that it was about 100 more than they normally have, plus they would normally have children in for part of the service (because there wasn't any room all the children stayed out at Sunday School for mass), so it must normally be pretty packed.

The Priest was Irish, which seemed quite stereotypical for a Catholic Priest. What wasn't stereotypical is that while they had sung responses, they had a folksy sounding band playing music for them, instead of the typical chant.

After Church I started cutting out some Pogs in Photoshop. After lunch I carried on cutting out Pogs in Photoshop.

I had received a reply back from WebFaction about how to monitor the memory usage of a program that doesn't run in the background, but they script they sent me was pretty useless as it just printed the memory usage at the point in time that you run it (so the same as ps).

Doing some googling I managed to cobble together a simple bash script that would record the output of ps (piped into grep for just the program I wanted to monitor) every half second for 30 seconds. Far from perfect, but good enough to get the stats on memory usage that I needed.

Running this script, I found (unsurprisingly) that ImageMagick used about the same amount of memory for resizing an image as php with the imagick extension does. Doing some googling I found this thread on the ImageMagick forums that explains how to limit the memory being used by ImageMagick.

So I added -limit memory 64 -limit map 128 to my ImageMagick parameters, and re-ran the memory monitoring script, and while ImageMagick took a while longer to run (though still finished within 30 seconds), it now didn't use tons of memory.

Next I tried to find out how to do the same thing in Imagick, and found this page (google cache as page doesn't seem to be loading properly, scroll up a bit to see the relevant section). That page says you should use
/*** Set memory limit to 8 MB ***/
$im->setResourceLimit( Imagick::RESOURCETYPE_MEMORY, 8 );

But when I modified my script to include the Imagick commands to limit memory usage, restarted PHP, and then ran my PHP script again, I could see (using top to monitor the php processes) that the memory usage was still going up to 467MB (or sumat similar).

I tried downloading the latest Imagick and the latest ImageMagick, but still the memory was being eaten up. So I filed a bug report for Imagick. Hopefully they will fix it shortly or tell me I'm doing something wrong and how to fix it, otherwise I'll have to make command line calls to ImageMagick from my PHP script.

The problem with doing that is that it's slower than Imagick and also I'll have to learn what the ImageMagick equivalent commands of the Imagick methods and options are that I'm using.

The weather today was sunny most of the day. There was a cloudless sunset, they sky wasn't particularly interesting, but seeing the sun is always quite nice (you can look at the sun without it burning your retinas when it's setting).

In the evening I watched Hapkido with Mauser, which was good, lots of action, and a young Sammo.

Food
Breakfast: ½ Grapefruit; Tangerine Marmalade on Crust of Toast; Cup o' Tea.
Dinner: Stir Fry Vegetables; Noodles; Soy Sauce. Pudding was 2x Oven heated Apple Pies wih Custard. Coffee.
Tea: Peppered Ham with Ground Black Pepper and Sweet & Crunchy Salad Sandwich; Clementine; Double Chocolate Muffin that L made at school; Cup o' Tea.

No comments: