User Profile Pictures, Exchange 2013, and SharePoint

SharePoint can import user profile pictures from the thumbnailPhoto attribute in Active Directory as a JPEG. This is done via setting up the Picture property within SharePoint’s User Profile Application. This is well documented elsewhere, so I won’t go into the process. However, if you set up a high quality image that fits under the thumbnailPhoto’s 100Kb size limit, user profile pictures within SharePoint look excellent!

Now, what happens when we introduce Exchange 2013 and want to leverage it’s new hi-res images for Exchange 2013 and Lync 2013? Jeff Guillet, an Exchange Server MVP, has a great article on how to use the new Exchange 2013 cmdlet, Set-UserPhoto. Set-UserPhoto does two things, it stores a copy of a very high resolution image (up to 648x648 px) in the Exchange 2013 user’s mailbox. The second thing it does is store a copy of the photo as a 48x48 px image in the thumbnailPhoto attribute.

So say SharePoint imports this 48x48 px image from the thumbnailPhoto attribute. The thing you’ll notice right away is that the image looks terrible. It isn’t the 48x48 px image itself that looks bad, but what SharePoint does to the image. In the Microsoft.Office.Server.UserProfiles.UserProfilePhotos.CreateThumbnail internal method, SharePoint creates 3 different thumbnails for the imported photo of varying sizes:

Large = 300x300 px

Medium = 72x72 px

Small = 48x48 px

SharePoint is also using the highest quality options available to scale the image from the System.Drawing.Drawing2D namespace:

graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

But, any way you slice it, a JPEG upscaled from 48x48 (thumbnailPhoto) to 300x300 px (user profile photo store) is going to look terrible. So how do you get the best of both worlds? My current suggestion would be to run this PowerShell, using both the Exchange Set-UserPhoto cmdlet and the Active Directory Set-ADUser cmdlet.

$photo = [byte[]](Get-Content C:\image.jpg -Encoding byte)
$photo2 = [byte[]](Get-Content C:\image100Kb.jpg -Encoding byte)
Set-UserPhoto -Identity jdoe -PictureData $photo -Confirm:$false
Set-UserPhoto -Identity jdoe -Save -Confirm:$false
Set-ADUser jdoe -Replace @{thumbnailPhoto=$photo2}

If anyone has a better suggestions, please let me know!

Trevor Seward is a Microsoft Office Apps and Services MVP who specializes in SharePoint Server administration, hybrid scenarios, and SharePoint Online. He has been working with SharePoint for 16 years from SharePoint 2003 on up, managing environments with terabytes of content for 150,000+ user organizations. Trevor is an author of Deploying SharePoint 2016 and Deploying SharePoint 2019. You can find him at /r/sharepoint.