9

My client uploaded a bunch of pics to an image library in SharePoint Online. There's a mix of portrait and landscape oriented photos, and the portrait photos are correct on disk, correct when viewed (from disk) in the web browser, correct in every image editing program that I have -- except SharePoint is storing and displaying them landscape no matter what.

Anyone ever seen this? Very odd behavior. I've tried clearing all metadata from the file, too, but no luck.

I also downloaded one of the photos, rotated it 180 degrees, and re-uploaded it (different file name). It's still showing the old way. There's something about these pictures that's making SharePoint force a specific rotation.

  • I have tried this solution but it doesn't work for me. When uploading a picture no EXIF data is added to the column and the picture is still displayed with the incorrect orientation. Has anyone else had the same problem? – Pezlin Jun 20 '17 at 10:09
  • Saving in PNG worked for me. Thank you – Vani Apr 17 at 15:39
5

JPEG-Images coming from modern cameras have EXIF data which describes the orientation of the image. When you view photos in modern image viewer (Google Picasa, Windows Picture Viewer >= Windows 8) then it is displayed in the correct orientation.

Webbrowsers and old image viewers (like Windows Picture Viewer <= Windows 7) show the images like they are saved, so they would not rotate an image for display, even if the EXIF data says, the picture needs rotation.

What can you do?

  • Don't rotate the images in your "old" Desktop Image viewer, it would rotate the image without changing the EXIF orientation data, which would give you a wrong orientation when you watch it in modern image viewers.
  • You can use a tool (search for exif autorotate) to normalize the orientation of all images, so they have the right orientation in all viewers including web.
  • Or you can - if you want to solve this problem in the future - build a ListItem EventReceiver which reads the EXIF orientation data and then rotates the image. So your EventReceiver would "normalize" the orientation on upload.

Here is a codesnipped how you can perform this:

/// <summary>
/// Return the orientation of the photo
/// </summary>
/// <param name="img"></param>
/// <returns>Orientation (1 = correct, 6 = requires rotation to the right, 8 = requires rotation to the left)</returns>                
public Int16? GetOrientation(Image img)
{
    try
    {
        // 274 Orientation (Short)
        PropertyItem propItem = img.GetPropertyItem(274);
        return BitConverter.ToInt16(propItem.Value, 0);
    }
    catch (Exception)
    {
        return null;
    }
}

Image image = new Bitmap(imageStream);
Int16? orientation = GetOrientation(image);

if (orientation.HasValue && (orientation == 6 || orientation == 8))
{
    // Now rotate it with some .NET features
}

Addition: I don't know, if your image viewer programs all sucks or if the browser displays the image in the other orientation based on EXIF data. Take a look on this article, the first answer.

Modern browsers have a css property, which is maybe used (or not used) by SharePoint to rotate (or not rotate) the image on view.

| improve this answer | |
3

Hi I actually resolved this without coding (we have an Office365 subscription / SharePoint online).

  • Open the Library.
  • Go to the ribbon.
  • Click on "Create Column".

Type of information: Managed Metadata

Column Name: wic_System_Photo_EXIFVersion

Then the only other setting to change, is the "manage term set". Switch to "customize your term set". On my case, once I did that and accepted the default value that it popped up, I was able to save (click OK).

After the column was added, the photos rotated properly (even the ones I had already uploaded).

| improve this answer | |
  • It's not showing any default value after creating, could you share it with us? – Yugo Jun 12 '18 at 17:56
2

I saved all images in PNG format and it all worked fine.

| improve this answer | |
0

I too tried the 1st step, without any change. Saving as PNG corrected the issue. I additionally saved the PNG back to JPG (to save space) and it displayed correctly in SharePoint.

| improve this answer | |
-1

Rotate the image in paint and save it as a PNG. Upload to SharePoint and it's the correct orientation.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.