Express middleware that processes served images according to the query string