New PC, New Semplice Bug, New Semplice Version!

Three days ago, I treated myself to a new PC (a Beelink SER 5, using an AMD Ryzen CPU that's a lot more modern than the 2017-vintage i7 I was using before). I took the opportunity to install a fresh copy of EndeavourOS, an Arch derivative that I've used before and which tends to ship with a lot more up-to-date software than my previous distro, Debian 12. It's all working extremely well and is pretty much silent, which is essential given its location within my music listening room (though I do need to get a quieter keyboard: a previous choice for a mechanical keyboard with Cherry Blue switches means mine currently sounds like a thousand typists are at work!)

Anyway, the point is that everything I need to work worked well ...until I tried to tag up a new CD rip using my own Semplice program. The tagging bit itself was fine, but trying to embed album art within the FLACs produced this weird error:

magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/746

...followed by the album art JPG file itself being deleted (as it should be after a successful embedding operation), but no album art actually being embedded at all. 🙁 Since this was all working fine at the beginning of the week on Debian, I assumed my new choice of distro must have been to blame. That particular error message is not an unknown problem on Arch (and its derivatives) after all. See, for example: https://bbs.archlinux.org/viewtopic.php?id=177557

Finding a solution to this reported problem was tricky, however. There was mention of 'uninstall ImageMagick and then install libjpeg and libjpeg-dev, then re-install ImageMagick', but this fell at the first hurdle because uninstalling ImageMagick means unpicking a web of dependencies that clearly threaten to break the entire distro. So, instead, I did:

sudo pacman -S libjpeg libjpeg-dev

...to install some JPG dependencies, followed by:

yay -S imagemagick-full

...which causes a source code version of ImageMagick to be pulled from the Arch User Repository (AUR) and freshly compiled for you. It takes a while, but at the end of it you're told:

loading packages...
resolving dependencies...
looking for conflicting packages...
:: imagemagick-full-7.1.1.39-1 and imagemagick-7.1.1.39-1 are in conflict. Remove imagemagick? [y/N] y

The operating system detects that the new ImageMagick conflicts with the existing version and offers to let you replace the latter with the former. I answered 'yes' and agreed to replace the 'standard' ImageMagick with the freshly-compiled version.

Did this make Semplice start embedding album art correctly? No. The problem remained exactly as it was ... so I swiftly did a

sudo pacman -S imagemagick

...to put back the original ImageMagick program as it had been before. For laughs, and in desperation, I converted my JPG to PNG with a third-party program and tried Semplice tagging with that instead, but with the same result: "no decode delegate" for that image format exists either. Then I tried tagging with a new JPG entirely (and a new PNG, just in case), in case the image I was working with had some invisible, internal defect that was tripping things: the same 'no delegates' error message appeared every time.

So, at this point I'm tearing my hair out and thinking something is profoundly wrong with ImageMagick before thinking "maybe I'll just take a look at my own code". At which point I discovered lines like this:

if [ $CONVPROG == "convert" ]; then convert "$ARTWORK" -quality 100 -resize 1400x1400\! /tmp/albumart.jpg; elif [ $CONVPROG == "magick" ]; then magick "$ARTFILE" -quality 100 -resize 1400x1400\! /tmp/albumart.jpg; fi

What that's saying is "If you're using Version 6 of ImageMagick (as I would have been on Debian 12), your image manipulation program is called 'convert', but if it's Version 7 (as I am on EndeavourOS), the program is called 'magick'". This reflects the change that was released for Version 2.01 of Semplice. So far, so good. But look more closely at the code again: if you're using version 6 of ImageMagick, you use the 'convert' program to embed an image whose name is held by a variable called "$ARTWORK". But if you're using Version 7 of ImageMagick, mysteriously (and completely erroneously), the variable name is now "$ARTFILE". Well: this is it!

My code carefully sets the variable "$ARTWORK" but never sets anything called "$ARTFILE", so Semplice on a new EndeavourOS installation is busy telling ImageMagic to convert "null" into a JPG, which it simply didn't understand and couldn't do. The fault, dear Brutus, was entirely my own therefore: Version 2.01 introduced a bug by mis-stating a variable name at a crucial juncture and I obviously didn't test very well on distros that use ImageMagick Version 7, since my own Debian 12 was perfectly happy with ImageMagick Version 6 and thus only ever encountered an instruction that used the correct variable name.

For fun and games, I then checked my code for Semplice's Tagging Menu, Option 5 which is a standalone option to embed album art, and the code for that reads:

if [ $CONVPROG == "convert" ]; then convert "$ARTFILE" -quality 100 -resize 1400x1400\! /tmp/albumart.jpg; elif [ $CONVPROG == "magick" ]; then magick "$ARTFILE" -quality 100 -resize 1400x1400\! /tmp/albumart.jpg; fi

...which, you'll note, uses the "ARTFILE" variable name ...but does so consistently, regardless of which version of ImageMagick you're using. This code therefore works on Debian 12 and EndeavourOS -and if I'd been in the habit of manually embedding my album art with this Option 5, I might never have noticed the error inherent in the auto-embedding that happens when you use Option 1.

I thought this an interesting tale to tell, for several reasons. One, I'm afraid this isn't the first time I've used variable names that are variants of each other: ARTFILE and ARTWORK sound sort-of similar, but if I set one and don't set the other, the code will break. I need to get more consistent on this sort of thing. Second, I obviously don't test thoroughly enough. I did test Semplice 2.01 on all the distro families when it was released, but I obviously wasn't paying attention to the details. And three, it's funny how you can go down a 'technological rabbit hole', installing this, uninstalling that, following someone's script here, rolling it back there... when all the while it's your own code that's the problem... and yet it's the last thing you check! Silly me.

Anyway: all of the above is by way of prelude to the announcement that Semplice Version 2.07 has been released, as something of an emergency bug-fix, and that you should upgrade to it immediately (by taking the Miscellaneous menu, Option 3). Supply the sudo password when prompted and let the new code, with consistent variable naming, be pulled down and installed. Quit Semplice thereafter and then re-launch it when you're ready. Semplice 2.07 on platforms using ImageMagick 7 will then be able to auto-embed album art, whether JPG or PNG, as usual once more. My apologies for the stuff-up in the meantime!

Leave a Reply

Your email address will not be published. Required fields are marked *