Refactored image manipulation functions to display.js so they can be used by all layers