Removing unused images

Is it possible to remove unused images from the public folder when building?

More Detail
Here’s what I’m doing.

  1. I copy high resolution images into my content folders.
  2. I use Hugo Image Processing to create appropriately sized images for each page from the original high resolution art.

The high resolution images in step 1 still live in the content folders and are thus accessible on the published web site if you know the URL (which is pretty easy to figure out based on the names of the image processed filenames).

I want to use the original images to generate my resized variants, but I do not want the high resolution original artwork to be made available.

Is there anyway to strip out the original art? I have no direct links to the original artwork on any generated page.

No… But I’m not sure why you need to start out with a “high resolution” original.

It’s true, I don’t need to include the highest resolution images, but it was easier. Since I was already doing image processing in hugo, making a smaller resolution to work on first is a bit redundant.

The thing is, the image processing step is kind of optional in Hugo, and it isn’t possible for us to detect if the original is used or not without additional information – which would make it more complex and I’m not sure it would be worth it.

(I know this thread is old now; but in case someone ends up looking for an answer to this again in the future)

I went looking for something similar a couple of months ago and ended up rolling my own solution using a custom shortcode and a postprocessing step; there’s details and code examples here.