Create various image sizes ad hoc

You could, but I wouldn’t recommend doing it on the fly as it would take up unnecessary page resources each time the user loads the page. A better way to do it would put in the add_image_size hook you mentioned into the functions file, then install a plugin to regenerate thumbnails. https://wordpress.org/plugins/regenerate-thumbnails/ I’ve used this one in the past and worked very well. You should only have to install it, generate the thumbnails once, and then you can uninstall the plugin. The thumbnails should generate on each upload after that.