Converting WordPress PNGs to WEBPs

I have a “legacy” business website I wish to keep online for archival purposes. The problem is that in building this site over a period of a decade we were fairly particular about keeping a lot of the images on it good enough for print quality as this was a useful service to customers. A decade later and our wp-content/uploads folder weighs in at 30GB.

Sure, that’s not a tonne of data by modern standards … but I just want to host this on a little personal VPS and don’t want to pay for extra storage just for the sake of it.

Obvious modern solution? Convert all the PNG images to WEBP.

Should be easy, right? Look, there’s a load of plugins for this! Oh, wait, no, nearly all of them make an extra copy of the images in WEBP format rather than convert the existing files. I can understand why, but at least give me the option? Mostly it’s complex overlays of your existing media. Some even try to monetise it – how about using a third party service to “optimise” your images?! Madness… I’ve got a perfectly good ImageMagick thanks. The one plugin that might have done what I wanted wasn’t maintained and didn’t work on my up to date WordPress install.

So… down to fundamentals. Manually convert the files with a shell script, and then poke at the database. How hard can it be? It turns out: not super hard. I’m not sure I’d recommend this be copied verbatim on a production site (use a staging copy at least) but it seems to have worked for me. My biggest issue was thumbnails and the fact they store the data for these in a manky string encoded format in the database, but for this task at least there’s a plugin to help.

Step 1: Manually convert all PNGs to WEBPs:

That took about 45 minutes to crunch my PNGs and after this my 20* folders had shrunk from 27GB to 5.5GB! Nice.

But of course my media files in WordPress are all broken now!

Step 2: Go hit the database with a hammer…

What you should find now it the key media URLs work from the media library, but all thumbnail/resize versions are broken images. Rather than muck around processing WordPress’s horrid string encoding of the metadata for these files I found a plugin that can force the regeneration of all thumbnails. This takes a good long while to run, but cost me zero time coding or mucking about and just did its thing.

Step 3: Install plugin to regenerate resized images

This is the plugin: Force Regenerate Thumbnails

When it is installed find in your WordPress admin:

Tools > Force Regenerate Thumbnails

JPG files?

Yeah, you can do them too… just replace “png” above with “jpg” or “jpeg” where required – noting that typically the file name is “jpg” but the mime-type is “image/jpeg” (but you could have “jpeg” file extensions present too I guess.) I repeated the above process for JPG files and further shrunk the data size down from 5.2GB to 3.2GB.

DANGER WILL ROBINSON! DANGER!

I hope this post might be helpful to someone, but it comes with a big caveat… there are errors. This isn’t perfect. I’ve found a few cases where files ended up missing, and I had to copy them back in. No biggie for me, this is just an archive. (I do have the original data in backups in the unlikely case I ever want it.)

Definitely use a sandbox, don’t play in production, and test the results!

Allotment?!?!

So… yeah… that whole idea about blogging about the allotment fell by the wayside a bit. However the allotment itself did not so much and all sorts has happened on it since the previous post.

Mostly these days I have a Mastodon (“Fediverse”) presence where I share allotment progress (and other junk).

And also just for fun I’ve started doing some lo-fi “vlogs” over on that other hive of scum and villainy known as YouTube.

The drone photo below is an early one taken August 2021 of the plot after we commenced ground-works, clearing the site and building some raised beds.

Below is from November 2022 – with the pollytunnel built. We were lucky enough to get some pollytunnel frame for free from some local farmers, so only had to buy the polythene and some timber. It’s short, but high, and has yielded us some excellent crops of tomatoes and chillies.

We’ve since taken on the plot to the right above and commenced clearing and reconfiguring that – I’ll need to get some fresh drone photos.

Our Upwell Allotment – Prologue

I have not “blogged” for a very long time… aside from a bit of work-related writing, personal blogging pretty much faded out for me when I went down the route of running my own business. The last post on this personal site was December 2014 – 5 months before I started the wholesale business. – and that post was just a link to the old beer blog, where the last post was in January 2017 (as an off-shoot from work related thoughts)… Time? Spare time? Forgeddaboutit! However, I am going to try something… and see if I can make it stick… because I’m tired of nearly 100% of my waking hours being about the businesses I’m involved in…

Upwell Allotments – from the entrance off Stonehouse Road

So… on the 9th of July 2021 we met a bloke at the Upwell Allotments to view some available plots – having enquired about renting one a couple of months ago. There were none available at the time, so we asked to be put on the waiting list. Now there are three available – an interesting back-story being that the 2 ones beside each other belonged to one bloke (we are told he was known by some as “Mr Potato” owing to this being pretty much what his entire double-plot was devoted to) and the third single plot belonged to his wife. For whatever reasons all three were pretty much abandoned this season – age the culprit by the sound of it, life getting on, things like managing allotments getting difficult. To be honest, there is an air of sadness to that back-story. So we shall move swiftly on.

All three available are somewhat over-grown. Though not in a very established way thankfully, the double-plot seeming to have been tilled probably last season and just having this season’s fresh weeds growing. The double also has two trees on the central boundary – a well established walnut and an oak sapling. Whilst the single is completely empty aside from some low raised beds hiding under the overgrowth. Personally I’m quite attracted to the trees, as much as I am aware they will have an impact on light and water in their vicinity – and also I prefer the “blank slate” nature of the plots without the existing raised beds. So we have opted for the more southerly of the double plot – I’d have probably have gone for both – a big plot with the walnut in the middle – but the allotment manager pretty much led with the fact they wouldn’t let out doubles so that probably saves us biting off more than we can chew!

There’s little to add about the plot right away. It is weedy, the soil is soft, there seems to be the odd potato amongst the weeds, and I think there are some berry bushes up the back. Looking at it front-on there is a well maintained neighbour on the right with a fence between made of pallets. The front-right corner is where an existing gate is, so as the fence to the south casts a lot of shadow we’ll keep the gate location and run a path all the way down this side to the back I reckon. Then build a small storage shed at the back corner for keeping items dry – we are warned to not keep anything valuable on site (fair warning) – crime is minimal, but they have the occasional opportunistic miscreant checking sheds for tools worth thieving. We will probably put a set of compost heaps along the back edge … and other that that there’s plenty to plan and think about. Not to mention budget and scrounge. Building a garden can be expensive… thankfully due to the business I do have some “free” resources, like a constant stream of pallets… and cardboard… loads to work out.

For context I have some images – a zoom-in of the site, which is between Stonehouse Road and Upwell Cemetery off St Peters Road. I think it is accessible by foot through the cemetery, but this is to be confirmed. Let’s zoom in on the site:

The allotment site is highlighted in dark blue, and our plot in cyan with the yellow star.

This is 12.5cm per pixel imagery, and this third photo is zoomed to 12.5cm per 2px, so it goes a bit grainy. If you look carefully you can see the skeleton of the walnut in the middle of the NW edge between the plots. This satellite imagery is from 10th April 2020 and you can see the plots seem to have been recently dug over.

The two images below with the fancy “before and after” widget show Google Satellite imagery on the left versus the April 2020 imagery, the Google Imagery isn’t dated but I’ve deduced it is probably from around 2017. If you check the site on Google you can see it wasn’t in much use at that point. What you can see is that it was whilst the walnut tree was in leaf, as it’s a proper green blob in the middle there. And the sun was lower on the horizon so you can see shadows cast including from the fence on the SE neighbouring plot. I’ve marked the plot out with little cyan dots.

The other thing I’ve been thinking about already is: where is the sun! A fairly basic and fundamental element, and one I was already roughly working out in my head whilst on site picking a plot… the single plot 2-plots to the NW of the double was the clearest for sunlight, no trees, no fence… but the trees really won me over. It was clear that the walnut was going to create a lot more shade in the NW plot than the SE one so SE it was on that measure.

On the left we have the sun transit on the day of the winter solstice, and on the right the the sun transit on the day of the summer solstice. There’s not a great deal more to think about with respect to this – we can see that generally most of the plot is going to get good sunlight for most of the year. With only a little worry in winter with the fence shadowing the ground – so that’s where we will put the path. In summer the tree will only cast some shadow on our plot coming into the evenings between 4pm and sundown on the day of the summer solstice. And that’ll be mainly across the back corner where I plan to put compost bins and other utility area stuff. The sun maps were generated using this useful website: https://www.sunearthtools.com/dp/tools/pos_sun.php

Anyway, that’s it… I leave you with a pair of photos across the plot as we saw it on Friday. One from each front corner… Looking forward to getting stuck in, with some trepidation as to whether I’ll have the time and energy to keep it going.

tmux — a super quick “getting started” “cheat sheet” for screen users

Google didn’t find this for me. Google FAIL, Internet FAIL. No computer biscuit for you!

If you’re a pretty fundamental screen user then this is about all you’ll need to start out with tmux:

Goal screen tmux
Start named session: screen -S mysessionname tmux new-session -s mysessionname
Attach-to (and detach) named session: screen -rd mysessionname tmux attach-session -dt mysessionname
Detach from session from within: ^A then d ^B then d

Why use tmux over screen — I have no idea yet! At the very least the default scrollback behaviour seems to be more user-friendly. On that note while you can shift-PgUp/PgDown well enough as in a normal terminal it keeps resetting to the bottom. I’m not sure if this behaviour can be disabled but I found that ^B-then-PageUp takes you into a useful scrollback-view-mode that you can get out of by simply pressing q.

Scrollback aside, I’ve only just started to try to use it, thus this post… nothing against tmux so far!

It’s newer, shinier, and supposedly more eXtensible than screen. Yippee?

Those tmux command lines are just crying out for some shell aliases.

More: Google for it, this is just “baby-steps” bootstrapping information here… there’s plenty of advanced information out there. Want vi-like scrollback navigation?

(The first few Google results I checked didn’t actually provide the useful details with respect to working with named sessions.)

There, super-rare tech entry from me. It’s been years. That’s what a head-cold, no alcohol, and 1.5 litres of coffee does to you… productivity!

Kaput

What do you get when you mix together failure to implement a reasonable backup scheme, hard-drive failure, and “oh, I thought it was supposed to be RAID-1”? A right pain in the bloody arse!

Gradually putting things back together – starting with the ale.gd site. I do have copies of all the entries I’ve written but they’re in a funny old format. I’m not using blosxom any more, I’d made a lot of customisations to the code and it seems I’ve lost half of them! So, trying wordpress – reluctantly. It has the advantage that it “just works”, a bonus as I don’t have much time for personal hacking. Sadly I also seem to have lost the photo album content. Not the actual photos, I have all of them backed up, but I’ve lost the commentary I’d added to the albums.

Ah – think of it like a house fire. It feels a bit like that. In fact, as far as personal data goes an actual house-fire would probably have been less damaging!

Café Snowdon

Note: This entry has been restored from old archives.

Café Snowdon!
Café Snowdon!

This could be an interesting theme: climb mountains and make espresso at their peaks.

Late on Friday August 7th we drove off for Wales, leaving home at 17:00 when I wanted to leave at 16:00. Always last minute things to do! The 209 mile drive from Hitchin to our destination was fairly uneventful, the lowlights being a bit of slow traffic on the M1, and being tailgated by arseholes on windy Welsh valley roads (who end up going even slower when I drop 20 miles per hour because I have an asshat in a Land Rover shining his lights straight through my back windows at point blank range.)

Our destination was the Hafod-y-llan National Trust campsite, luckily Mr Land Rover was going to the cityfolk campsite at the other end of the lake. By the time we got there it was dark, certainly dark enough that torches were required to put our little tent up. Alas, we’d only packed one instead of the two we should have had. After wandering the little camp ground for a bit we settled on a clear patch on a bit of a slope, we’re quite happy with slopes really. A nearby camper kindly lent us his head torch and we were all set up in 10 minutes. After some more fiddling we eventually got to bed at 23:00.

Hafod-y-llan
Hafod-y-llan

It was a slightly rough night of sleep for two reasons. First, I’d worked out how the ends of the tent could be adjusted to improve airflow – I, perhaps, “improved” the airflow a bit too much. The idea being reduction of condensation. The two of us cause quite a lot of this over a night, it is almost as if it somehow rains on the inside of the tent. Our tent is a dual-skin though, so this causes only minor difficulty in the morning. I wipe down the inside of the door with one of our chamios-like micro towels. If we’re to pack up or tents that day, as we were every morning on our Lakes hike, we then combine our efforts, and towels, to towel down the entire inside (and then the outside if it has rained.) Though this seems involved, it really doesn’t take all that long. One of the prices you pay for putting two people in a very small tent perhaps.

The second reason was that we’d unthinkingly let Yaël traipse off with one of our sleeping bags (for a friend she was travelling with.) On the day we were to leave we realise this, oops! So we had one sleeping bag between us, unzipped to be used like a blanket. It wasn’t too bad in the end, but not ideal.

We got up nice and early in the morning, 6AM for me. And prepared to trek off. Putting the bits we wanted for the day into Kat’s pack, which I was to wear. And a few items of food into a micro pack we have for Kat. Kat’s pack doesn’t fit me too well, but it is fine when the weight is only about 6 or 7kg. To begin the day we wandered down the driveway of the campsite to Bethania, where the Watkin Path up Snowdon begins, and where there also happens to be a Café. The café opened at 08:00, 10 minutes after we got there, so we waited. The café is huge, an old chapel in fact. It was bought by a group of locals I’ve read, and converted to its current use as a place of refreshment. Alas, their espresso is terrible, but that is no surprise. At 08:30 we were on the Watkin path, on our way to Snowdon’s summit.

By Afon Cwm Llan, Looking back down the route to Nantgwynant
By Afon Cwm Llan, Looking back down the route to Nantgwynant

At first the Watkin path is a leisurely stroll through woods and fields. Passing some intriguing old stonework. Essentially some very straight and raised paths down steep slopes. You’d think they’re old train lines, except that they’re very steep and don’t seem to take logical routes as compared to other train lines in hilly regions. One cuts straight up a buttress of Yr Arran, following a gradient reminiscent of a rollercoaster ramp. Funny place for a rollercoaster though! Some research reveals that these are the paths of slate inclines, and that this one, in fact, was never completed.

Incline
Incline

Passing this puzzling sight we’re on an impressively paved stone path up the valley of Afon Cwm Llan. This is a beautiful watercourse, given sunlight and a few degrees more warmth I doubt I could have resisted going for a dip in one of the many spa-sized pools of crystal clear blueish water (is it blueish due to the copper in these mountains I wonder?) The path passes some interesting stone buildings at a narrow point in the valley, some sort of fortification perhaps? Fortifying what though? The old ‘net is littered with references, the closest fitting of which is that it could have been the residence of the master of the slate mine.

There are a few more buildings along the path, as it makes its way up the valley. Finally there is a long one with a track heading out from it which loops around and forms a well defined road-like track on the other side of the valley. We wonder if this links up to the crazy-steep line on the other side of that ridge. An engine house of some sort perhaps? (I’m going to have to look all of this up when I get home. No Internet in the middle of a field in Wales!) Now, much later, I can look this up and it seems most likely that the long building is the barracks which housed the slate mine workers during the weekdays. The slate mine itself is said to have only operated for about 40 years, the slate there being of low quality. Modern evidence of this is said to be visible in how overgrown with grass many of the old tailing heaps are. This indicates that there was much dirt dug up with the slate, which isn’t at all good I take it. I presume they kept going in the hope the dirt would go away … but eventually hope, or money, ran out.

Barracks - home of slate mine workers during the week
Barracks – home of slate mine workers during the week

After passing the “engine house” the path becomes steeper, though still well paved. The stretch up the side of the valley is the most picturesque leg of our hike. Views above, views below, and since we aren’t in the clouds yet, views for miles around. We can even see the coast from up here. Plus, there are goats, goats with huge horns, goats cannot be beaten.

Bwlch Ciliau, Y Llywedd behind us
Bwlch Ciliau, Y Llywedd behind us

Rough stone steps take us up to the top of the ridgeline, Snowdon’s buttress out to Y Lliwedd. This is Bwlch Ciliau, where the path flattens out and follows the ridgeline over Bwlch Saethau. (Note that, this being Wales, I can only guess that the names near peaks and valleys are actually names I can apply to said peaks and valleys!) The walk along this ridge provides for some excellent photos if you follow one of the minor tracks off to the right. You find yourself at the top of a huge cliff looking down on Glaslyn, it is an excellent view for a photo.

On Bwlch Saethau, Glaslyn far below
On Bwlch Saethau, Glaslyn far below

The ridge takes you from about 750m to the 825m mark, where the going gets tougher. The route turning into quite a scramble as you make it up the final 200m to the peak. By the 800m mark we were in cloud, so just like our Scafell climb the summit looks like it won’t be giving us much of a view. A little sad, I cross my fingers and hope it’ll clear before we descend.

The last 50m of ascent is something of a stroll. It is all a little strange, we begin to hear the chuff-chuff of a steam engine, and soon a large building looms out of the fog. Then we hit the people… it is like a shopping mall. We skirt the building, past people clustered around the building entrance sucking on fags, looking a lot like they would rather be elsewhere. Fathers and husbands dragged along for the ride perhaps. Then we’re there, a short stone platform with two sets of stairs and the trig-point at the centre. It is crowded with people.

More than one use for coffee!
More than one use for coffee!

We wander around to the more sheltered north eastern side of the platform, using it as a wind break. Not bothering to venture to the top in a hurry, we can wait for a break in the crowd. I get out my little meth-burning stove and fill-er-up. We almost had a major disaster on this trip, I forgot to bring fire. I use a flint to light the stoves, which is a case of lighting either meths or wax-impregnated card (Hammarö paper.) It works surprisingly well. Unfortunately it didn’t come with us! We were somewhat lucky that the café at the bottom of the Watkin Path sold lighters and matches, so I bought a lighter. All hunky dory now right? No. I don’t have a lot of experience with lighters, and didn’t realise how crap your typical lighter is. This one doesn’t like to light if there is anything so much as a breeze, it lit inside the café just fine, which is the only place we tested it. On top of Snowdon all it would do is spit a few sparks, not good enough to light meths. So I had the smart idea of applying an old trick from when I was a kid, adjusting the +/- wheel so that the + was even more +! As soon as I took the silver shield off the lighter the wheel fell out and it was only by luck that the little bit of flint was jammed and didn’t fly off. Now I had to get the flint back down the little hole, compressing the spring. This is hard to do at the best of times, but with numb fingers close to impossible! With the aide of the tweesers from Kat’s pocket knife I put it back together… after 15 minutes and almost losing the flint twice! I extra-plussed the + and we were soon back in action!

One more step back... Enjoying espresso at Snowdon's summit
One more step back… Enjoying espresso at Snowdon’s summit

Café Snowdon espresso was enjoyed, we even made second shots. At least this amused some of the multitude of people up there. Including a couple of guys who were enjoying some beers they’d brought up with them (on foot, not by the train, so respectable in a way especially as one of them had brought both pints up as a surprise for the other.) They took some photos for us and we took some for them. We took some photos on the trig-point platform as well, though I now realise I never even bothered to look at the plaque on the trig point.

Next, Kathlene keen on some hot food, we headed for the actual café that is up there. We squeezed in, it is a huge space so having to squeeze indicates how packed the place was, then immediately I turned around and squeezed out. Insane! Horrible! I promised Kat we’d find some hot food after our descent and we began our downward route. Alas, the cloud never cleared.

Looking down the Pyg Track, Glaslyn afore, Llyn Llydaw aback
Looking down the Pyg Track, Glaslyn afore, Llyn Llydaw aback

I’d worked out a full circular walk in advance. After the hard trek up the south side of Snowdon we were to take a more leisurely route downhill to the east, before following the valley south west and back to the camp. This begins by heading north from the summit and then east down the Pyg track, before descending onto the Miners’ track which runs alongside Glaslyn and Llyn Llydaw.

Talk about busy! This route was a bumper-to-bumper highway of human traffic. Very frustrating at times as most of them make their way along the track very slowly and there are several stretches where overtaking isn’t possible, and waiting for oncoming walkers is necessary. Aside from the difficulties posed by the popularity of this route it provided some wonderful views. Most of the time the view down the valley over the lakes is present, and all the time the steep walls to the north and south loom overhead. From the shores of Glaslyn we could see the spot where we took the photo of ourselves on Bwlch Saethau with Glaslyn far below. On the western side of Glaslyn towering cliffs running straight up to the summit of Snowdon, lost in cloud, dominate the scene.

Looking up to Bwlch Saethau we took our photo looking down on Glaslyn from the V in the ridgeline
Looking up to Bwlch Saethau we took our photo looking down on Glaslyn from the V in the ridgeline

The route along Glaslyn and Lyn Llydaw is flat and wide, allowing you to focus more on the scenery than where you’re putting your feet. As with much of this countryside there are ruins littered around the landscape which intrigue the mind. In this area most of these high ruins are mining related, generally either slate or copper. By Glaslyn and, further down the track, Llyn Teryn are the remains of miners’ barracks. While, most impressive, is some sort of mine working building on the shore of Lyn Llydaw.

As you make your way along the lakes you pick out other remains, some foundations and what seems to be the line of an old raised railway. There is a causeway cutting across Llyn Llydaw then a more modern structure which is presumably a valve house feeding the large pipe running down the valley (this, it turns out, feeds a small hydro power station in the valley which was built in 1908 and is still put into operation when required.)

Copper works by Llyn Llydaw
Copper works by Llyn Llydaw

The rest of the walk to Penn-y-Pass continues to be straightforward and before long you find your self at an ugly car park. There isn’t much here, I had hoped for a nice little pub, but there is just a caf which can do you a solid hot meal. From Penn-y-pass you could catch a bus back around to Bethania, but we did the valley walk.

This home stretch took us down Afon Trawsnant, then Afon Glaslyn. From not long after Pann-y-Pass to well past the power station this path is very wet. Good high boots with reasonable waterproofness are highly recommended! The path takes you behind the veritable metropolis of the fancy campsite to the north-east of Llyn Gwynant, then on behind the lake itself. The walk behind the lake takes a fairly high route and provides for some excellent views down over the lake. This was also the best area for us to gather sticks for our excellent little Bush Cooker, my pockets were soon bulging with nice dry wood.

Dinner time! Mmm... fire
Dinner time! Mmm… fire

A few fields later we’re back at the Hafod-y-llan campsite. We’d set out at about 0800 and got back at 17:00, with at least an hour’s worth of stop time along the way. Our 17:00 return gave us plenty of time to chill out, make some coffee and dinner, and relax. Quite an excellent day all up.

We’re calling this walk the Devil’s Circuit… I do hope you can see why.

Devil
Devil

Our path took us up quite a steep route, which was clear and well paved all the way to Bwlch Saethau. The final ascent towards the summit became quite loose and confused at times, with hands being required at some points. I can see why this route is considered quite dangerous in winter. At one point you’re traversing a scree slope that ends with a cliff, imagine it covered in ice and snow! One way ticket to splat. The summit of Snowdon is very civilised, too civilised really. Scafell Peak wins any summity goodness competition hands down.

We will go back, but in the off season, when the train isn’t running… hm, perhaps I should get some ice axes and crampons for that one 😉 Meanwhile, I’ve been playing with generating SVGs of these walks, the most interesting of which is elevation over distance covered.

Snowdon Walk – Elevation over Distance
(click here for a larger version)

If you can’t view SVGs (i.e. you use a retarded web browser like IE) then you won’t see the image above. If you care… use Firefox (and no, I don’t think Firefox is great, I think it is a pile of crud.)