Adding ability to pass image extension as a parameter to get the required image format.