It seems SharePoint generates thumbnail file name using the following format:
thumbnailUrl = <filename>_<fileextension>.jpg
Based on that, the following REST endpoint shows to get thumbnail file content:
/_api/web/getfilebyserverrelativeurl('{thumbnailUrl}')/$value
Example
var webUrl = "https://tenant.sharepoint.com";
var fileUrl = "/PublishingImages/sample.png";
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var requestUrl = String.Format("{0}/_api/web/getfilebyserverrelativeurl('{1}')/$value",webUrl,GetThumbnailUrl(fileUrl));
var response = client.GetAsync(requestUrl, HttpCompletionOption.ResponseHeadersRead).Result;
var fileContent = response.Content.ReadAsByteArrayAsync().Result;
where
public static string GetThumbnailUrl(string fileUrl)
{
return System.IO.Path.GetFileNameWithoutExtension(fileUrl) + "_" + System.IO.Path.GetExtension(fileUrl) +".jpg";
}
Update
Probably the better option would be to get image thumbnail url via EncodedAbsThumbnailUrl
property:
- Get image thumbnail url using request:
/_api/web/lists/getbytitle('<image library title>')/items(<item id>)?$select=EncodedAbsThumbnailUrl
- then request thumbnail file content:
/_api/web/getfilebyserverrelativeurl('{thumbnailUrl}')/$value