And this line divides by 24, so you end up overall dividing the number of pixels by 8.

I was reasonably happy with the factor of 8 you had before, though I do think you ought to check the file size of some sample photos.