Because AMAZINGLY I have FINALLY got my films developed I once again needed to resize some images. It had been about a year and I think when I moved my NetBSD install from 32-bit to 64-bit I must have not bothered re-installing ImageMagick. So I went to build it from Pkgsrc as I knew the binary required X11; However, it seems like ImageMagick on Pkgsrc now requires X11, whereas the last time I was able to build it quite easily without. One of the reasons I use NetBSD is because it is possible to install it easily without X11 - I do not see the point in having X11 on a server and I'm far too stubborn to give in. So next I tried installing the ImageMagick binary on my NetBSD laptop, but the combination of failing hard drive and the sheer power of Pentium III and 128MB RAM means it just isn't up to resizing photos; It can just about display them though.

The next option was searching for alternatives and fortunately I found mention of VIPS and now, like everyone else who had never heard of VIPS and only ever used ImageMagick before, I think, "How on earth did I not hear about VIPS before?!". VIPS is REALLY GOOD. Not just from the point of view of using it (it resizes my photos instantaneously), but that it is also easy to build.

This made packaging it pretty straightforward once I'd stopped being an imbecile: I couldn't understand why I could build it directly from source so easily and yet when building from a Pkgsrc Makefile it couldn't find the relevant libraries. Well, I'd made a stupid mistake and put my .includes after .include "../../mk/bsd.pkg.mk" and so they were being ignored*. Once I finally figured that out the rest was easy thanks to VIPS being so portable anyway.

All I need VIPS for is the vipsthumbnail command. I use the following two options:

vipsthumbnail --size=500x1000 --format=%s_500.jpg images/myfullresphoto.jpg

to create an image that is 500 pixels wide. The x1000 is a bit of a hack as vipsthumbnail doesn't support 500x like ImageMagick does. So as long as I specify a vertical dimension that gives a ratio longer than anything I'll ever have in portrait, I'll always get an image that is 500 pixels wide; VIPS does keep the aspect ratio automatically.

vipsthumbnail --size=100 --crop --format=thumbnails/%s_500_t.png images/myfullresphoto.jpg

to create the actual thumbnail. The --crop option gets it square.

I still need to do some amendments to the package: Since VIPS is primarily a library I guess I should add a buildlink3.mk file; Also I have initially only added Jpeg and PNG support as that is what I needed, but I should add Tiff support; And finally, I should probably turn all those into build options, since VIPS is highly configurable (as far as I can tell, you can actually build it with no image file format support whatsoever just fine - don't know why you'd do that though?).

* I then had an "aha!" moment and went straight to Ledger and thought I'd be able to remove my horrible hacks as I'd made the same mistake there, but "Nope!". Ledger is still having none of it and I can still only get it to build from a Pkgsrc Makefile with those hacks.