Function for making thumbnail of jpg, png and gif