Was the image upside down? Sometimes stuff coming out of iOS is stored in a different orientation than it appears on the screen. (There is some metadata in jpeg that says to rotate it before displaying - browsers typically ignore this for backwards compatibility.)
how is it upside down?
That wrong result makes sense if you compare the word shapes with one of them upside down. 180-deg rotated p is d and so on.