A bit refactoring - getting format of the source image