modified functions
added functions to maintain images ratio