changing error handling to dir when failing to open a corrupt image