Taking nice snaps of things is a breeze if the lighting is good (i.e., sufficient), or if you’ve got a camera on a mount, but that’s not what we’re dealing with here: I want to snap pics in a frictionless manner, because I don’t have no time for no futzing around.
Over the years, I’ve tried a bunch of different cameras, but within my (peculiar) constraints, it’s just hard to not end up with blurry, out of focus images with bad white balance. What I’m currently using is a Sony a9 II camera with a 24mm lens (fixed lens since I can’t change focal length and hold both the camera and a comic book at the same time), set at f/12 (because I’m snapping pics of comics that I’m often holding in an angled way to avoid reflections, and anything less than that (at this distance) will mean that half the book is out of focus) and 1/25 (because anything slower than that will mean that the book is blurred from either my comic holding hand or my camera holding hand shaking).
(Auto white balance, though, auto focus, and I have to adjust the brightness of the image throughout the day/night by adjusting the ISO.)
See what serious problems I’m having!
But that’s not what this blog post is about: It’s about image transfer.
For almost a decade I’ve been using Toshiba FlashAir SD cards to transfer images from whatever camera I’ve been using to my laptop (and then automatically into Emacs). It works… fine… but there are some janky things about it.
The main problem is that the wifi range of the card is basically half a meter. That’s not really that surprising — I mean, it’s got a tiny antenna, and it’s inside a metal camera body. The amazing thing is that it works at all — it’s an engineering marvel for sure, having an entire computer with wifi and a web server in an SD card.
But that range means that I have to have a wifi Access Point running on my laptop. Which is easy enough, but when the laptop’s wifi runs in dual AP/client configuration, the wifi speed drops to, like, a tenth of the normal speed. Which is annoying. So I only take the AP up when blogging, which means that I have to have a daemon for taking the AP up/down running as root to make that happen automatically etc, and that’s just kinda janky.
(And the reading speed of the FlashAir card is pretty bad, so if I want to examine the image on the camera (that ▶️ button), it takes three seconds (!) to load.)
While most cameras these days have wifi capabilities themselves, the functionality needed hasn’t really been there. The previous camera only supported uploading images manually, and nobody has time for that. The camera before that required running some kind of server software on a Windows machine, and do I look like I have a Windows machine?
But!!! It turns out that Sony has put exactly what I (and any sane person) need in the firmware for their nicer cameras for a few years now. 1) The camera connects to a given wifi and 2) if connected, uploads everything you snap to a server via ftp automatically! It’s perfect! No manual interventions, and no janky special servers — just standard software on the server (i.e., laptop) side.
This excellent article explains how to set things up on the Sony side. (It’s the perfect kind of article — straight to the point, and goes through every single step. Not like this junky blog post!)
Figuring out how to get things to work on the Linux side took me a few hours, so that’s why this blog post exists.
The easiest ftp server to set up on Linux is probably vsftd, so that’s what I’ve gone with here. (And this recipe is for Ubuntu, but I think it’s similar on most Linux distributions.)
First create a user. We’ll be logging in as this user from the camera. Let’s call the user sony, and prep it a bit:
adduser sony mkdir /home/sony/ftp chown sony.users /home/sony/ftp chmod a-w /home/sony
So the /home/sony/ftp directory is where the uploaded files will go. We make /home/sony read-only, because we want to use a chroot jail for the user so that we get a bit more security: We only want this user to be able to alter things in /home/sony/ftp and not have access to anything else.
apt install vsftpd
Then open /etc/vsftpd.conf in an editor, and find the commented-out lines and change them to:
write_enable=YES local_umask=022 chroot_local_user=YES
And now we get some multiple choice bits: My Sony a9 ii camera only supports TLS v1.0, and that’s so old that modern Linux distributions don’t support it, and apparently on Ubuntu 22.04 (which I’m running here), there’s no way to enable it in vsfpd. At least I haven’t found any way to do so. But ideally we’d have:
And enable “Secure Protocol” in “Destination Settings” in “Server Setting” under “Ftp Transfer Func” on the Sony camera. But that doesn’t work for this combination of camera/laptop. On the other hand… it doesn’t really matter that much, anyway. *gasp* Yes, it’s shocking, but with a chrooted user, and this only being used on the home wifi (and WPA2 encryption, janky as that is), the danger of using an unencrypted connection is, in this case, minimal.
So I’m using unencrypted ftp to upload images.
Anyway, so this is what this looks like in action:
So I snap and it takes a couple seconds for the image to appear in this Emacs buffer. Here’s that image:
So… kudos to Sony for getting the functionality right, and *rolls eyes* on using such an old version of the TLS libraries that they don’t support TLS v1.2.
(Although I haven’t tried updating the firmware — it’s possible that newer versions work fine.)
And perhaps the biggest advantage of using this over the FlashAir card is that the Sony a9 camera has good wifi range, so I don’t have to have the camera near my (laptop) AP to make things work.