Fun with printers/scanners!

So, I have an old (10 years ish) Brother scanner/laser printer I've had for ages. It only talks over USB and is connected to our home server that runs home automation and a bunch of other stuff. I've got several scripts set up to make it convenient to scan / move files in handy places etc, that run on the server attached to it. This was all working well.

Then sometime last week, I noticed the JPEGs coming out of scanning were corrupt.

So today I got to investigating, did the basic `scanimage` command to produce a JPEG without my surrounding scripts.

No error messages. and a file of approximately right size is produced but `file` just reads it as "data" rather than recognizing a jpeg. Image viewers fail to load it.

I open the JPEG in a text editor and it has a full webpage prepended before the actual image data. When I edit it to remove the HTML and save it, it works fine as a JPEG.

So, what gives? What changed?

Well. Also last week, I bought a brother inkjet printer; much newer. This sits in a different room and connects to the wifi, but isn't otherwise connected to a computer, let alone the server I mentioned.

And sure enough, when I unplug this new printer, `scanimage` works properly.

I am slightly at a loss how to approach this one; I guess just keep the wifi-connected machine turned off unless I need it? Don't quite want to go digging into `sane`'s internals to sort this one out 😅

Okay so `scanimage` has a `--device-name` parameter I can use. `scanimage --list-devices` first dumps the same HTML and then, indeed, lists two devices. One connected via USB, and one on the network.

Given that the HTML just appears in unrelated command output I'm not super confident that specifying the device will actually prevent the problem but let's find out.

Yeah, that worked! Hooray. Now to tweak all my scripts to actually specify the device when scanning.