Thanks @adrian for the info, and sorry for not checking the DB schema before replying.
So then @apastuszak: assuming you are still interested in a script to help with this, you could do something like:
artpaths=$(sqlite3 ~/.config/beets/library.db 'select artpath from albums where artpath not null;')
find /path/to/my/music -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.gif' | while read f
echo "$artpaths" | grep -qF "$f" || echo "$f"
done > untracked-images.txt
Which will log all PNG, JPEG, and GIF files that are not tracked in the DB’s
artpath field into the file
untracked-images.txt. You can then review the list, and if all looks good, run
rm $(cat untracked-images.txt) to delete them all.
Caveat emptor: my beets database does not have any artwork tracked by that
artpath column, so I couldn’t test this script completely. In particular, I do not know if
artpath will be an absolute path, or a path relative to the music root. So the script might need slight adjustments for that. Respond here if you still need help.