By default the Hardware Camera is Landscape(almost many devices) , so at-once you capture , i automatically rotates to 90 degree - As if it is taken in the landscape .
Thats why you get the image right when you take in Landscape and 90degree rotated image while taking in Portrait mode .
- detect the orientation of the device and if it is in portrait , rotate to 90 degree clockwise , so that it would tally when it rotates 90degree anti-clockwise .
 
Use the below code to detect the orientation ,
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) 
    {
        super.onRestoreInstanceState(savedInstanceState);
        if (savedInstanceState != null) 
        {
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
            {
                // code in portrait - rotate to 90 degree
            }
            else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            {
                    // code in landscape - do nothing
            }
        }
    }