Would it be possible to create dynamic galleries based on tags (or terms)?

What I would like is to tag each photo with for instance "a b c" and another photo with "b c" and another with "c". Then a dynamic gallery would be able to show 1 photo when just selecting the "a" tag, 2 photos when selecting the "b" tag and 3 photos when selecting the "c" tag. Combinations of tags should be possible too.

Maybe this is already possible in some way (using taxonomy or some other module)?

Especially for product pages this would be very handy!