Moved detectVerticalSquash logic to image initialization so that it is only executed once