1

User Profile Service is importing photos from AD. Sync and profile photos are being created fine. I've identified one profile picture that will not display in IE8, eventhough the picture exists. When viewing the user's profile with Chrome (and suspect other browsers), it will display fine. The picture also does not display in the org browser on any browser.

I did some research and found that there is a known thing in IE that will not display pictures that were saved with CMYK encoding (http://www.plaveb.com/blog/cmyk-images-not-displayed-in-internet-explorer and http://blog.rodneyrehm.de/archives/4-CMYK-Images-And-Browsers-And-ImageMagick.html).

I've tried to determine if the file is CMYK encoded, using the following PowerShell (sourced from here: https://stackoverflow.com/questions/446834/how-to-detect-if-a-jpeg-contains-cmyk-color-profile):

cls 
Add-PSSnapIn "Microsoft.SharePoint.PowerShell" -EA 0

$web = get-spweb "http://mysite.myco.com"
$profilePhotos = $web.Lists["User Photos"]

$folder = $profilePhotos.RootFolder.SubFolders["Profile Pictures"]
$files = $folder.Files | sort "Name"

foreach($file in $files)
{
  if (($file.Name -like "*problemphoto*")
  {
     $stream = $file.OpenBinaryStream()
     $image = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $stream

     $flagValues = ([enum]::parse([type]"System.Drawing.Imaging.ImageFlags",$image.Flags)) 
     $flagValues
  } 
}

The results of the flags did not indicate a CMYK scenario. In fact, it seems to indicate RGB.

ColorSpaceRgb, HasRealDpi, HasRealPixelSize, ReadOnly

I compared this with a known good profile pic and the results matched.

Also, I copied the picture down locally, opened it in Paint, and resaved the file. I then manually uploaded the file to the profile photo library in the my site host and the picture worked in IE.

Anyone seen issues like this with profile pictures? Is there anything other than the CMYK thing that could cause this issue?

1 Answer 1

1

Looks like the file extension did not match the true file type. In this particular case, the file name indicated ".jpg", however, it was truly a ".bmp".

I wrote a script to help determine if there were any other examples of this:

cls 
Add-PSSnapIn "Microsoft.SharePoint.PowerShell" -EA 0

function GetTrueFileFormat($rawFormatGuidString)
{
    $Bmp = "b96b3cab-0728-11d3-9d7b-0000f81ef32e"
    $Emf = "b96b3cac-0728-11d3-9d7b-0000f81ef32e"
    $Exif = "b96b3cb2-0728-11d3-9d7b-0000f81ef32e"
    $Gif = "b96b3cb0-0728-11d3-9d7b-0000f81ef32e"
    $Icon = "b96b3cb5-0728-11d3-9d7b-0000f81ef32e"
    $Jpeg = "b96b3cae-0728-11d3-9d7b-0000f81ef32e"
    $MemoryBmp = "b96b3caa-0728-11d3-9d7b-0000f81ef32e"
    $Png = "b96b3caf-0728-11d3-9d7b-0000f81ef32e"
    $Tiff = "b96b3cb1-0728-11d3-9d7b-0000f81ef32e"
    $Wmf = "b96b3cad-0728-11d3-9d7b-0000f81ef32e"

    switch($rawFormatGuidString)
    {
        $Bmp {"Bmp"; break}
        $Emf {"Emf"; break}
        $Exif {"Exif"; break}
        $Gif {"Gif"; break}
        $Icon {"Icon"; break}
        $Jpeg {"Jpeg"; break}
        $MemoryBmp {"MemoryBmp"; break}
        $Png {"Png"; break}
        $Tiff {"Tiff"; break}
        $Wmf {"Wmf"; break}
        default {"unknown"}
    }

}

function IsSameFileType([string] $ext, [string] $rawFormat)
{

    $ext = $ext.Replace(".", "")

    if ($ext -eq "jpg" -and $rawFormat -eq "Jpeg")
    {
     return $true
    }

    if ($rawFormat -ne $ext)
    {
       return $false
    }
    return $true
}



$web = get-spweb "http://my.xyz.com"
$profilePhotos = $web.Lists["User Photos"]

$folder = $profilePhotos.RootFolder.SubFolders["Profile Pictures"]
$files = $folder.Files | sort "Name"
$files.Count
foreach($file in $files)
{

    $fileName = $file.Name
    $fileInfo = new-object System.IO.FileInfo -ArgumentList $fileName
    $ext = $fileInfo.Extension     

    $stream = $file.OpenBinaryStream()
    $image = New-Object -TypeName System.Drawing.Bitmap -ArgumentList $stream

    $rawFormatGuidString = $image.RawFormat.Guid.ToString()
    $trueFormat = GetTrueFileFormat $rawFormatGuidString
    $sameFormat = IsSameFileType $ext $trueFormat
    if ($sameFormat -ne $true)
    {
       $fileName
       Write-Host "NOT SAME FORMAT!!" -foregroundcolor red
    }  
}

Hope this helps someone else sometime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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