Added image trim and improved scaling