initial import of extracted code
fixing app context and some imports
added new trim and crop functionality
added check for outof bounds crop_x_offset