views:

74

answers:

2

Dead code is easily recognised and eliminated by having code reviews, however, when it comes to images - unused images still get into our version control. Is there any clean way of organising graphic content so that a direct correlation exists between web pages and image files?

In our current project, we use create master PNG files then export the required layers for development purpose. Recently I figured out that there is some bloat in the images folder. Doing a search for image names in code helps but it is very painful when it needs to be done for hundred odd images. So asking the forum for suggestions

A: 

If you have a 1 step build and can test for dead links, then you should be able to write a script that would do a clean checkout of the project, delete a single image and build & test the project. If no errors pop up the image is unneeded.

It would take a long time to run (maybe days depending on the project size) but that's computer time, not man-hours.

BCS
+1  A: 

You could walk the website with a crawler (like wget) and remove any image not touched (i.e. not listed in your logs.)

A quicker way would be to just dump all the image file names found in your code.

grep -o -e \w*?\.png    (caution: untested regex)
Chris Nava