I would like to create the list of images no longer used in any content item so they can be purged from the disk. What is the best method to generate such a list?
I'm not sure there is a best method on how to do this. The only way I can think of requires a bit of effort. That is, generating a list of all the images in the content table in the database (and potentially in modules, menus, banners, etc... Any place where images are referenced which is a lot), compare that list against all the images on the files system, and then compare between each list and remove the images which aren't used.
So this would look like:
1) Get a list of all the images in com_content's database table. Dump all the rows, regex for
<img src="images/stories/an-image.jpg" />. Another way is to use php's strip_tags() method and only allow the tag. I find this easier than writing a regex generally. Basically run a php script to build this list for you as a text document or csv.
2) Get a list of all images on the site. You could use grep from the command line to do this I believe. You could probably do it with some sort of recursive php filesystem method as well.
3) get both into a spreadsheet and run some sort of comparison against each column to see if the image is used, compiling a list of unused images in a third column.
Personally, unless you have a crap ton of images I'm not sure this is worth the effort. But you'll have to determine that pending your use case. Also there may be a far more simple solution which someone else will have to suggest!
If you have your access logs, you might be able to pull out all the requested image files in the last X months (you will need to play with all this data). So these are very probably in use in your actual site (yet not 100%). Depending on your content and site structure and if your site is not really huge (i.e. 1 million articles), it is very probably that the remaining are probably not in use (again not 100%).
I find this solution as easy one. Backup the images prior to deletion. You can track later on for 404 errors trying to open specific files and you may decide to restore these.
It is dirty solution, but there is really no easy way. The best option would be to follow Chad advise and to write your own parser.
While no extensions existed when the question was asked, as of August 2018 there are at least a couple of extensions that can apparently find and delete orphaned images:
VX orphanImages (paid extension)
"VX orphanImages plugin scans your Joomla! site images folder to find items, which are not used in any content on site. It uses the core Media component to mark orphaned images in the list, so you can decide whether to keep or remove them."
ImageManager (free/paid versions)
"ImageManager for Joomla! allows you to move and rename images without losing the image-link in Articles and Custom HTML Modules. Simply drag & drop your images to restructure and clean-up your website. It also can list all unused images and delete them."