added on resize event to adjust images when resizing window

This would add a resize event to update images based in the current window size.

One possible optimization:
Don't call main() on every resize but only after a timeout, so the code does not run continuously when resizing.