Hello Rick et al,
I have a WWC web/VFP app that uploads iPhone/iPad photos to my IIS server, via plUpload. After some investigation, it appears my iPhone X sets the EXIF orientation to "Normal" when you use the phone/camera in landscape position, and "Rotate 270 degrees" when you shoot portrait.
Once uploaded to my Windows IIS server, on a PC or Mac (Safari) browser the Landscape shot is heads up, but the Portrait shot appears rotated 270 degrees, which makes sense. However looking at the website images on the iPhone or an iPad (Safari), the orientation is heads up on both images. This is really confusing stuff. So the iPhone seems to be adjusting the orientation based on the EXIF to make them always heads up, but the PC/Mac browser, or IIS, is not.
Most of my users tend to use the camera in Portait, so this is a big issue.
On the website, I give my users the option to rotate the photo using Rick's RotateImage function, which as I understand it uses GDI+, which I don't know much about, or even how to find it on my server to see what version it might be. However while RotateImage (GDI+) rotates the image nicely, it does not change the EXIF. So now the Portrait shot looks heads up on the PC/Mac, but going back to the iPhone/iPad, it's tipped over to the right 90 degrees.
So I'm wondering if anyone else out there has dealt with this, or knows if there's a way to update the EXIF when you rotate the image. I've played around with VFP in the past reading the JPG file at a low level using FREAD(), but not sure trying to read and write JPGs is such a good idea. Ideally I'd like to rotate it if necessary and set the EXIF to normal when its uploaded.
Thanks, Rod
I think the way to do this is to strip all the extra EXIF data from the image.
wwDotnetBridge has a static ImageUtils()
class that can be used for this:
Something like this (off the top of my head):
loBridge = GetWwDotnetBridge();
loBridge.InvokeStaticMethod("Westwind.WebConnection.ImageUtils","StripJpgExifData",lcImgFile,90);
Another thing you can and probably should do anyway is use some sort of image cleanup tool. I use Pingo (and Pinga which is a GUI front end) here on the message board and on my blog to pack all incoming images after my code resizes very large ones. I believe Pingo (which is a command line tool) also strips EXIF data.
+++ Rick ---
Great!!! That solves the issue between the browsers and iPhone orientation. Thank you so much! I just inserted it in the onUploadComplete function just before I move the image out.
Now, I'm wondering if this wonderful class has a way to read the EXIF first so I can tell if the photo is coming in rotated. Then I could use RotateImage to set it upright before I move it as well.
No my helper doesn't access the EXIF data. But I'm sure you can find code or a .NET library that does that you can use with wwDotnetBridge.
+++ Rick ---