code for scaling and saving of original dimnesions